引用js
<script language="javascript" src="jquery-1.10.2.js"></script>
js
<script type="text/javascript"> $(function () { var $citys = $("#cityname li"); //for 循环 for (i = 0; i < $citys.length; i++) { alert($citys[i].innerHTML); } //$().each(function(index,element)); index:当前下标 element:遍历的对象 $citys.each(function (index, element) { alert(index + " " + element.innerHTML); }); //$.each(obj,function(index,element)); index:当前下标 element:遍历的对象 $.each($citys, function (index, element) { alert(index + " " + element.innerHTML); }); }); </script>
html
<ul id="cityname"> <li> 东莞 </li> <li> 深圳 </li> <li> 广州 </li> </ul>
posted on
浙公网安备 33010602011771号