开发者

jQuery - finding an element with multiple HTML tag attributes in it

开发者 https://www.devze.com 2023-03-16 02:12 出处:网络
Why using this: var parent = $(\'div.form.offer_mails\'); var period = parent.find(\'input[type=checkbox,name=timeperiod]\');

Why using this:

var parent = $('div.form.offer_mails');
var period = parent.find('input[type=checkbox,name=timeperiod]');

I get this (exception in my Mozilla Firefox Error Console):

Error: uncaught exception: Syntax error,开发者_JAVA技巧 unrecognized expression: [type=checkbox,name=timeperiod]

Isn't it possible to search an element with more than one attribute and it's value?

Please explain and solutionize my problem. :)


Yes, in this way:

var period = parent.find('input[type=checkbox][name=timeperiod]');

Note that this is also a valid CSS selector.

0

精彩评论

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