jQuery检查是否没有同级具有类 Semua供应商 万事达卡 签证 JCB 工会工资 莱尼亚
我的html是这样的jQuery检查是否没有同级具有类 Semua供应商 万事达卡 签证 JCB 工会工资 莱尼亚,jquery,html,list,siblings,Jquery,Html,List,Siblings,我的html是这样的 $(".next-list li").click(function() { if ($(this).hasClass("all-selected")) { if (!$(this).hasClass("filter-selected")) { $(this).siblings().removeClass("filter-selected"); $(this).siblings().children(":last-child").css({
$(".next-list li").click(function() {
if ($(this).hasClass("all-selected")) {
if (!$(this).hasClass("filter-selected")) {
$(this).siblings().removeClass("filter-selected");
$(this).siblings().children(":last-child").css({
"display": "none"
});
$(this).addClass("filter-selected");
$(this).children().last().css({
"display": "inline-block"
});
} else {
$(this).siblings().addClass("filter-selected");
$(this).siblings().children(":last-child").css({
"display": "inline-block"
});
$(this).removeClass("filter-selected");
$(this).children().last().css({
"display": "none"
});
}
} else {
if (!$(this).hasClass("filter-selected")) {
$(this).addClass("filter-selected");
$(this).children().last().css({
"display": "inline-block"
});
$(".all-selected").removeClass("filter-selected");
$(".all-selected > span:last-child").css({
"display": "none"
});
} else {
$(this).removeClass("filter-selected");
$(this).children().last().css({
"display": "none"
});
console.log($(this).siblings("filter-selected").length);
if ($(this).siblings("filter-selected").length == 0) {
$(this).parent().children("li:first-child").addClass("filter-selected");
$(this).parent().children("li:first-child").children().last().css({
"display": "inline-block"
});
}
}
}
});
此
是未选择过滤器的任何li
有什么想法吗?感谢您的帮助:)由于选择的
过滤器是class,您应该在之前添加一个点
if($(this).siblings("filter-selected").length == 0) {
$(this).parent().children("li:first-child").addClass("filter-selected");
$(this).parent().children("li:first-child").children().last().css({"display": "inline-block"});
}
选择的筛选器是一个类,它应该与点
$(this)一起使用。兄弟姐妹(“.filter selected”).length
@AmanRawat…….我觉得很愚蠢:'))谢谢你,好先生!:)
if($(this).siblings("filter-selected").length == 0) {
$(this).parent().children("li:first-child").addClass("filter-selected");
$(this).parent().children("li:first-child").children().last().css({"display": "inline-block"});
}
if($(this).siblings(".filter-selected").length == 0) {