Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery检查是否没有同级具有类 Semua供应商 万事达卡 签证 JCB 工会工资 莱尼亚_Jquery_Html_List_Siblings - Fatal编程技术网

jQuery检查是否没有同级具有类 Semua供应商 万事达卡 签证 JCB 工会工资 莱尼亚

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({

我的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({
        "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) {