jquery 는 전체 선택, 전체 선택, 반 선택 작업 을 실현 합 니 다.

4719 단어 jquery
 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 2 <html>

 3 <head>

 4     <title>    </title>

 5     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

 6     <meta name="description" content=""/>

 7     <meta name="keywords" content=""/>

 8     <script type="text/javascript" src="../jquery-1.4.4.js" ></script>

 9 

10     <script type="text/javascript">

11         function selAll(){

12             $(".ho").attr('checked',true);

13         }

14         function selAllNot(){

15             $(".ho").attr('checked',false);

16         }

17         function selFan(){

18             //    

19             //       、  、        

20             for(var i=0; i<$(".ho").length; i++){

21                 var flag = $(".ho:eq("+i+")").attr("checked");

22                 $(".ho:eq("+i+")").attr("checked",!flag);

23             }

24         }

25     </script>

26 </head>

27 <body>

28 <h2>     </h2>

29 

30 <input type="checkbox" name="hobby[]" id="hobbya" class="ho" value='a'>  

31 <input type="checkbox" name="hobby[]" id="hobbyb" class="ho" value='b'>  

32 <input type="checkbox" name="hobby[]" id="hobbyc" class="ho" value='c'>  

33 <input type="checkbox" name="hobby[]" id="hobbyd" class="ho" value='d'>  

34 

35 <br /><br />

36 <input type="button" value="  " onclick="selAll()" />

37 <input type="button" value="   " onclick="selAllNot()" />

38 <input type="button" value="  " onclick="selFan()" />

39 </body>

40 </body>

41 </html>

좋은 웹페이지 즐겨찾기