each遍历

it2022-05-08  6

<script> $(function () { $.each([52, 97], function(index, value) { alert(index + ': ' + value); }); }) </script>

 

 

假设页面上有这样一个简单的无序列表。

1 2 3 4 <ul> <li>foo</li> <li>bar</li> </ul>

你可以选中并迭代这些列表:

1 2 3 $( "li" ).each(function( index ) { console.log( index + ": "" + $(this).text() ); });

列表中每一项会显示在下面的消息中:

0: foo 1: bar

 

转载于:https://www.cnblogs.com/jiefangzhe/p/10779435.html


最新回复(0)