Given the following html, is there a selector that allows me to get both based on type
?
<input type="text" /> <input type="button" />
$('input[type=text || button]'); //for example, double pipes as an OR does not work
I went through the docs, but I couldn't find anything on the ability to use logical operators or a means of providing a matching list.
With jQuery, it is easy to select elements with a given attribute value. For example: var elements = $('div[attr1="value1"]');
that's because when you call the data method on the jQuery object, it returns the data for the first element in the nodeList. To get the data for all the div's you have to loop through the elements with the $. each method or use a mapping to retrieve the attributes in a list.
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order. An alternative to this combinator is the .
This should help:
$('input[type="text"], input[type="button"]');
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