假设页面上有这样一个简单的无序列表。
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