搜索范围标题属性的jQuery快速过滤问题


一号位
2024-12-26 02:52:30 (2月前)


我正在使用jQuery快速过滤器(https://github.com/syropian/jQuery-Quick-Filter),并且无法使用span标题属性过滤过滤器。

我改变了github代码……

2 条回复
  1. 0# 布偶的表弟派大星丶 | 2019-08-31 10-32



    通过将所有字符串合并为一个并使用indexOf对整个字符串而不是使用||,我能够使它工作。 (或)两者兼而有之

    失踪
    </强>


    现有
    </强>








    1. /*

        • Plugin Name: QuickFilter
        • Author: Collin Henderson (collin@syropia.net)
        • Version: 1.0
        • ? 2012, http://syropia.net
        • You are welcome to freely use and modify this script in your personal and commercial products. Please don’t sell it or release it as your own work. Thanks!
        • https://github.com/syropian/jQuery-Quick-Filter
        • https://stackoverflow.com/questions/42530073/jquery-search-image-title-attribute
          */
          (function($) {
          $.extend($.expr[‘:’], {
          missing: function(elem, index, match) {
          return (elem.textContent + elem.innerText + elem.title + “”).toLowerCase().indexOf(match[3]) == -1;
          }
          });
          $.extend($.expr[‘:’], {
          exists: function(elem, i, match, array) {
          return (elem.textContent + elem.innerText + elem.title + ‘’).toLowerCase().indexOf((match[3] || “”).toLowerCase()) >= 0;
          }
          });
          $.extend($.fn, {
          quickfilter: function(el) {
          return this.each(function() {
           var _this = $(this);
        •  var query = _this.val().toLowerCase();
        •  _this.keyup(function() {
        •    query = $(this).val().toLowerCase();
        •    if (query.replace(/\s/g, "") != "") {
        •      $(el + ':exists("' + query.toString() + '")').show();
        •      $(el + ':missing("' + query.toString() + '")').hide();
        •    } else {
        •      $(el).show();
        •    }
        •  });
        • });
          }
          });
          })(jQuery);
      • $(document).ready(function() {
        $(‘#txtSearch’).quickfilter(‘#list li’);
        });





        • ?

        • testing ?

        • carrot


        • now I can’t filter on title attribute but I can search on text between span tags








    登录 后才能参与评论