jquery当中NodeList的用法
例 1.2(NodeList.html)
<html>
<head>
<title></title>
<script language="javascript" src="jquery.min.js"></script>
<script language="javascript">
window.onload = function(){
var oEle = $("h2 a"); //选出两个符合条件的
for(var i=0;i<oEle.length;i++)
/*马克-to-win:注意oElements[i]虽然是个jquery对象,他也可以用innerHTML*/
oEle[i].innerHTML = "mark to win"+i.toString();
}
</script>
</head>
<body>
<h2><a href="#">马克-to-win</a>内容</h2>
<h2>内容<a href="#">马克-to-win</a></h2>
</body>
</html>
例 1.2_a:
<html>
<head>
<title></title>
<script language="javascript" src="jquery.min.js"></script>
<script language="javascript">
$(function(){
var oEle = $("h2 a"); //选出两个符合条件的
for(var i=0;i<oEle.length;i++)
/*注意oElements[i]虽然是个jquery对象,他也可以用innerHTML*/
oEle[i].innerHTML = "mark to win"+i.toString();
});
</script>
</head>
<body>
<h2><a href="#">马克-towin</a>内容</h2>
<h2>内容<a href="#">马克-towin</a></h2>
</body>
</html>
更多内容请见原文,原文转载自:https://blog.csdn.net/qq_44594371/article/details/103061462