搜索过滤器不显示链接文本

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

我已经使用 Bootstrap 5 实现了页面搜索过滤器,但该过滤器仅显示文本内容,而不显示 a 标签中包含的任何内容。链接到下面的 JS Fiddle:

https://jsfiddle.net/mfen723/rozy16pt/17/

我想让过滤器显示 a 标签内的内容(因为它们出现在页面上)并保持链接可点击。

我实现的过滤函数是:

$(document).ready(function() {
  $("#searchInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#research *").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
javascript search filter bootstrap-5
© www.soinside.com 2019 - 2024. All rights reserved.