0

How can i to change below function for case insensitive search all div elements(div[id*=music]) which has a link contains search_text;

function search(el){ var search_text = $(el).val(); //if(!search_text) return false; var search_block = $('div.music_box'); search_block.children('div[id*=music]:hidden').show(); search_block.children('div[id*=music]').filter(':not(:has(a:contains('+search_text+')))').hide(); console.log(search_block.children('div[id*=music]')); } 

jQuery v1.10.2

2
  • Don't over-use DOM selectors. Use a filtering callback, case-insensitive string comparison is trivial there. Commented Jun 14, 2014 at 15:46
  • Bergi, can you to show me example with filtering for my function? ) Commented Jun 14, 2014 at 15:54

1 Answer 1

1

Try this:

jQuery.expr[':'].Contains = function(a,i,m){ return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0; }; 

and then you ca use it like: $("element:Contains")

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.