JQuery Attributes&utilities css, Manipulation, $.each등

JQuery Attributes&utilities css, Manipulation, $.each등

< script type = "text/javascript" >

$( function () {

//select태그와 change 이벤트는 세트처럼 생각해

$( "#selTest" ).on( "change" , function () { //id : selTest에 change이벤트가 발생할 때, function실행

console .log($( "#selTest" ).val());

console .log($( this ).val()); //!!! this도 사용가능 !!!

console .log( this .value);

//세개다 결과는 동일

}) //.on("이벤트명", 처리함수) <-- 이 형태로 자주 사용

console .log( "-----------------------------------" )

$( "#selTest" ).on( "change" , function () {

var userid = $( "#userid" ).val(); //userid의 value를 var userid에 저장

var passwd = $( "#passwd" ).val(); //userid의 value를 var userid에 저장

console .log(userid, passwd);

$( "#passwd2" ).val(passwd); //#passwd2 에 #passwd의 value를 저장해서 나타나게함

})

//button은 click과 세트

$( "button" ).click( function () { //버튼을 클릭하면 #passwd2에 passwd의 value 저장

var userid = $( "#userid" ).val();

var passwd = $( "#passwd" ).val();

$( "#passwd2" ).val(passwd);

})

})

< / script >

< / head >

< body >

< select id = "selTest" >

< option > aaa < / option >

< option value = "bbb" > bbbb < / option >

< / select >

아이디:

< input type = "text" name = "userid" id = "userid" value = "아이디입력" >

< br > 비번:

< input type = "text" name = "passwd" id = "passwd" value = "비번입력" >

< input type = "text" name = "passwd" id = "passwd2" >

< br >

< button > OK < / button >

from http://cocoshin.tistory.com/50 by ccl(A) rewrite - 2021-12-24 06:28:33