« Return

jQuery contains selector: case insensitive


$(document).ready(function() {
       
        var category = jQuery.url.param("category"); // http://projects.allmarkedup.com/jquery_url_parser
        category = category.replace(/-/g, ' ');
        // console.info(category);        
        
        $.expr[':'].icontains = function(obj, index, meta, stack){
        return (obj.textContent || obj.innerText || jQuery(obj).text() || '').toLowerCase().indexOf(meta[3].toLowerCase()) >= 0;
        };
        // find case-i and click()
        $("ul li a:icontains(" + category + ")").click();
       
       /*
        var section = jQuery.url.attr('file');
        // console.info(section);
        
        if ( section == 'color.php' ) {
          var project = jQuery.url.param("project");
          project = project.replace(/-/g, ' ');
          $("ul li a:icontains(" + project + ")").addClass('selected');
        }
        
        if ( section == 'design.php' ) {
          var client = jQuery.url.param("client");
          client = client.replace(/-/g, ' ');
          $("ul li a:icontains(" + client + ")").addClass('selected');          
        }
        */

}); // end document ready