Query 怎样当前的元素是某个集合中的第几个子集?

原文地址:http://topic.csdn.net/u/20101128/22/1e6b33b3-2eda-47c2-b437-5df353c05faf.html

jQuery(document).ready(function () {
$(
"div li").click(function(){
alert($(
this).prevAll("li").length);//要 prevAll 才行,prev只返回1
});
});


hzrui:
JScript code

jQuery(document).ready(
function () {
$(
"div li").each(function( i){
$(
this).click(function(){
var n=i;//这里通过传入的参数可以知道是第几个
alert("当前是第"+n+"个 <li>");
});
});
});

  

posted @ 2011-08-03 17:40  wangkangluo1  阅读(396)  评论(0编辑  收藏  举报