jQuery - Search image title attribute

前端 未结 5 2073
天涯浪人
天涯浪人 2021-01-24 01:38

I have been looking at this jQuery quick filter code here: https://github.com/syropian/jQuery-Quick-Filter

I\'d like to be able to use it to quick filter a list of image

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 02:32

    The quickfilter.js checks for elements textcontent and innertext only. Adding a condition to check for image title will do the job. Add elem.title as per below code in quickfilter.js

    $.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;
        }
    });
    

提交回复
热议问题