问题
I want to set to checked a checkbox input by value AND name..
<input name="email" type="checkbox" value="1" tabindex="2">
How can I do that? I need that both conditions are done.
This fails on &&
$("input[name=email] && [value='+i+']").attr('checked', true);
This code is into a for iteration and "i" is taking a numeric value. Thanks in advance for your time and help...
回答1:
Just use both selectors next to each other:
$("input[name=email][value=" + i + "]").prop('checked', true);
Any selectors that have no space between them are applied to the same element.
来源:https://stackoverflow.com/questions/14716459/logic-and-for-jquery-selector