jQuery attribute selector for multiple values

2020-01-26 10:55发布

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.

2条回答
爷、活的狠高调
2楼-- · 2020-01-26 11:35

Try this

$("input:text, input:button");
查看更多
一纸荒年 Trace。
3楼-- · 2020-01-26 11:50

This should help:

$('input[type="text"], input[type="button"]');
查看更多
登录 后发表回答