each() 方法规定为每个匹配元素规定运行的函数。
$("button").click(function(){ $("li").each(function(){ alert($(this).text()) }); });如果有多个li,那么会找到所有li并为每个li规定运行的函数