<html> <body> <ul> <li id="li01" class="text01">첫번째 id="li01" class="text01"</li> <li id="li02" class="text01">두번째 id="li02" class="text01"</li> <li id="li03" class="text02">세번째 id="li03" class="text02"</li> <li id="li04" class="text02">네번째 id="li04" class="text02"</li> <li id="li05" class="text03">다섯번째 id="li05" class="text03"</li> <li id="li06" class="text03">여섯번째 id="li06" class="text03"</li> </ul> <!-- ############################################################################# --> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script> $("body").append("<hr>"); var act01 = "class=text01 선택"; $("body").append("<input type='button' id='act01' value='"+act01+"'/>"); $("#act01").click( function(){ alert( $(".text01").text() ); } ); $("body").append("--->> <b>$(\".text01\").text()</b><br>"); var act02 = "class=text02 에 style 적용"; $("body").append("<input type='button' id='act02' value='"+act02+"'/>"); $("#act02").click( function(){ $(".text02").css("background-color","#DDDDFF"); } ); $("body").append("--->> <b>$(\".text01\").css(\"background-color\", \"#DDDDFF\")</b><br>"); </script> </body> </html>
- write by 꼬마갱이 2012.10.30 -
'SCRIPT야' 카테고리의 다른 글
jQuery 따라하기 - 10 (기초) (0) | 2012.10.30 |
---|---|
jQuery 따라하기 - 9 (0) | 2012.10.30 |
jQuery 따라하기 - 7 (0) | 2012.10.30 |
jQuery 따라하기 - 6 (0) | 2012.10.30 |
jQuery 따라하기 - 5 (0) | 2012.10.30 |