24.jQuery - 속성값 복사 ( 02.Selectors - 02.Text )
$(':text').메서드()
이런형식으로 쓰시면 모든 input type="text" 형식의 태그들이 타겟으로 설정됩니다.
02.Text.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title>Text 박스의 값 복사</title>
<style type="text/css">
.silver { background-color:Green;
}
</style>
<script src="../jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{ // 모든 텍스트박스의 배경을 Silver로 설정 $(':text').addClass("silver"); // 첫번째 텍스트박스의 값을 두번째 텍스트박스로 복사 $('#btnCopy').click(function() { $('#txtID').val($('#txtUserID:text').val()); });
});
</script> </head> <body>
아이디 : <input type="text" id="txtUserID" /><hr />
<input type="button" id="btnCopy" value="복사" /><hr />
아이디 : <input type="text" id="txtID" /> </body> </html> |
결과화면 |
[그림24-1] |