Jquery search for input containing specific text

0

What selector jquery that I use to search all inputs that contain specific text, for example I have several checkbox with different texts, then CA type and it searches all% with text containing CA, after that I will only display these and hide others.

    
asked by anonymous 14.09.2015 / 20:53

2 answers

2

Ideally, your checkboxes should have a value equal to the text you want to fetch.

So you can use jQuery queries

$("input[type='checkbox'][value*='Teste']")

For example

Notice the * = operator of the query, this is the same as "contains", ie it looks for any part of your string. If you want the text to be exactly the same, use = .

Example on finder: link

Edited

In case of using the data-text would be

$("input[type='checkbox'][data-text*='texto']")

More information about jQuery selectors at link

    
14.09.2015 / 21:10
0

You can do it this way:

$(":checkbox").filter(function() {
  return this.value == '5';
}).prop("checked","true");

or

$("input[type=checkbox][value=5]").prop("checked",true);​

DEMO: link

    
14.09.2015 / 21:04