Case insensitive jQuery :contains selector


/ Published in: JavaScript
Save to your folder(s)

This will extend jquery to have a :Contains selector that is case insensitive, the :contains selector remains unchanged.


Copy this code and paste it in your HTML
  1. // For jQuery 1.2
  2.  
  3. jQuery.extend(
  4. jQuery.expr[':'], {
  5. Contains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
  6. });
  7.  
  8.  
  9. // For jQuery 1.3 (thanks @user95227) and later you need
  10.  
  11. jQuery.expr[':'].Contains = function(a,i,m){
  12. return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;
  13. };

URL: http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.