This article describes the case-insensitive method of jQuery implementing the contains method. Share it for your reference. The specific implementation method is as follows:
// NEW selector [':'].Contains = function(a, i, m){ return jQuery(a).text().toUpperCase() .indexOf(m[3].toUpperCase()) >= 0; }; // OVERWRITES old selecor [':'].contains = function(a, i, m){ return jQuery(a).text().toUpperCase() .indexOf(m[3].toUpperCase()) >= 0; };
usage:
$("div:contains('John')")
Test HTML files:
<div>john</div> <div>John</div> <div>hey hey JOHN hey hey</div>
I hope this article will be helpful to everyone's jQuery programming.