jQuery :contains() selector uppercase and lower case issue

后端 未结 4 1589

My html looks like this





      
4条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 14:54

    Why not use the filter function, and pass in a function that uses a case insensitive regex?

    var filteredDivs = $("div.link-item").filter(function() {
        var reg = new RegExp(txtsearch, "i");
        return reg.test($(this).text());
    });
    

    DEMO

提交回复
热议问题