This article mainly introduces jQuery's case-insensitive method for implementing the contains method. The example analyzes the rewrite technique for the contains method, which has some reference value, for more information about how jQuery implements the case-insensitive contains method, see the examples in this article. Share it with you for your reference. The specific implementation method is as follows:
// NEW selector jQuery. expr [':']. contains = function (a, I, m) {return jQuery (). text (). toUpperCase (). indexOf (m [3]. toUpperCase ()> = 0 ;}; // OVERWRITES old selecorjQuery. expr [':']. contains = function (a, I, m) {return jQuery (). text (). toUpperCase (). indexOf (m [3]. toUpperCase ()> = 0 ;};
Usage:
$ ("P: contains ('john ')")
Test the HTML file:
John
John
Hey JOHN hey
I hope this article will help you with jQuery programming.