$("ul > li").click(function () { // http://www.sharejs.com   var index = $(this).prevAll().length; //prevAll([expr]): 查找当前元素之前所有的同辈元素 });