AND logic for jQuery selector

I want to check the box to enter a value by the value of AND name.

<input name="email" type="checkbox" value="1" tabindex="2"> 

How can i do this? I need both conditions to be met.

This does not work & <

 $("input[name=email] && [value='+i+']").attr('checked', true); 

This code is in for iteration, and "i" takes a numerical value. Thanks in advance for your time and help ...

+6
source share
1 answer

Just use both selectors next to each other:

 $("input[name=email][value=" + i + "]").prop('checked', true); 

Any selectors that have no space between them apply to the same element.

+15
source

All Articles