导读:jQuery 遍历each() 方法规定为每个匹配元素规定运行的函数。语法$(selector).each(function(index,element))<html><head><meta http-equ...
jQuery 遍历each() 方法规定为每个匹配元素规定运行的函数。
语法
$(selector).each(function(index,element))
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>B5教程网</title>
<script type="text/javascript" src="http://www.bcty365.com/statics/js/bcty365_js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("li").each(function(){
alert($(this).text())
});
});
});
</script>
</head>
<body>
<button>jQuery遍历each()函数输出每个列表项的值</button>
<ul>
<li>B5教程网</li>
<li>www.bcty365.com</li>
<li>程序信息网</li>
</ul>
</body>
</html>