jQuery cycle of each ()

/ * * 
   * Definition and Usage: $ (Selector) .each (function (index, Element)) 
   * each () function will run for each matching element function (returns false to terminate the cycle). 
   * each () function will match globally. 
   * /
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("li").each(function(){
      alert($(this).text())
    });
  });
});
</script>
</head>
<body>
<button>输出每个列表项的值</button>
<ul>
<li>11</li>
<li>22</li>
<li>33</li>
</ul>
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
</ul>

 

Guess you like

Origin www.cnblogs.com/tanjiyuan/p/11374532.html