搜索领域。如何编码。如果你找不到一个值

问题描述 投票:0回答:1

我写了这个JS代码

$("#itemSearch").on("keyup", function () {

  if ($("#itemSearch").val().trim() == '') {
    $(".card-content").show();
  }

  else {
    var value = $(this).val().trim().toLowerCase() ;
      $(".card-group").filter(function () {
      $(this).toggle($(this).text().trim().toLowerCase().indexOf(value) > -1)
    });
  }
});

并想说这样的话。

$(".card-group"):not.text()
alert ("1");

或者

$(".card-group").text ! value
alert("1");

有谁可以帮助也许?

问候Erya

jquery search filter negation
1个回答
0
投票

我现在知道答案了。它与include()一起工作!

$("#itemSearch").on("keyup", function() {

if ($("#itemSearch").val() == '') {
  $(".card-content").show();
  showPage(1);
  $(".pagination").css("display", "flex");
}

else {

var value = $(this).val().toLowerCase();

$(".card-group").filter(function() {
  $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});

$(".pagination").css("display", "none");

**if ($(".card-group").text().toLowerCase().includes(value)) {
  alert ("1");
}
else {
  alert ("2");
}**

}

});
© www.soinside.com 2019 - 2024. All rights reserved.