1.循环
1 <html> 2 <head> 3 <script type="text/javascript" src="/jquery/jquery.js"></script> 4 <script type="text/javascript"> 5 $(document).ready(function(){ 6 $("button").click(function(){ 7 $("li").each(function(){ 8 alert($(this).text()) 9 }); 10 }); 11 }); 12 </script> 13 </head> 14 <body> 15 <button>输出每个列表项的值</button> 16 <ul> 17 <li>Coffee</li> 18 <li>Milk</li> 19 <li>Soda</li> 20 </ul> 21 </body> 22 </html>
浙公网安备 33010602011771号