jquery中index实现列表中元素的显示和隐藏

var last = "";
var lastIndex = "";
$(".ykyw_list2 ul li").click(function(){
var current = $(this);
var currentIndex = $(this).index()+1;
if (currentIndex != lastIndex && lastIndex != "") {
last.removeClass("li_now");
last.next("div").hide();
}
$(this).addClass("li_now");
$(this).next("div").toggle();
last = current;
lastIndex = currentIndex;
})

原文地址:https://www.cnblogs.com/cornucopia/p/4162958.html