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