Posted By

magicrebirth on 09/21/10


Tagged

jquery text contains


Versions (?)

Case insensitive jQuery :contains selector


 / Published in: JavaScript
 

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

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

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

Report this snippet  

You need to login to post a comment.