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...
jQuery selectors allow you to select and manipulate HTML element(s). jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
jQuery selector: jQuery selectors are used to selecting the HTML element(s) and allow you to manipulate the HTML element(s) in a way we want. It selects the HTML elements on a variable parameter such as their name, classes, id, types, attributes, attribute values, etc. Example: HTML.
ID Selector: The jQuery #id selector selects the element on the basis of the ID attribute of the HTML tag. This selector is basically used when we have to work on a single element because an ID should be unique within a web page.
So far we have covered only three standard jQuery Selectors.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With