Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery attribute selector for multiple values

Tags:

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.

like image 366
mrtsherman Avatar asked Jan 25 '12 15:01

mrtsherman


People also ask

How to select multiple attributes in jQuery?

With jQuery, it is easy to select elements with a given attribute value. For example: var elements = $('div[attr1="value1"]');

How get multiple data attribute values in jQuery?

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.

Can we use multiple selectors in jQuery?

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.

What is multiple selector?

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 .


1 Answers

This should help:

$('input[type="text"], input[type="button"]'); 
like image 113
jabclab Avatar answered Sep 27 '22 22:09

jabclab