开发者

How to pass multiple condition to find function in Jquery

I wan开发者_运维知识库t to pass multiple conditions to Jquery find function e.g

$(selector).find("input[type='text',id='txtId']") //this is not a right way

what is the solution?


The normal way to do it is like this:

$("#txtId")

Why? Because you can only have one thing with that id, and therefore there is no need to use find. But maybe you could come up with a better example of what you are trying to do. It seems like I'm missing something here :)


You may find you answer here http://api.jquery.com/multiple-attribute-selector/

The docs say jQuery('[attributeFilter1][attributeFilter2][attributeFilterN]'). Anyway, if you try to select <input type="text" id="id1" class="cls1"/> by id and class, this is the way:

$('input#id1.cls1')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜