jQuery attribute selector for multiple values

2020-01-26 11:13发布

问题:

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.

回答1:

This should help:

$('input[type="text"], input[type="button"]');


回答2:

Try this

$("input:text, input:button");