2011-06-28 19 views
4

屬性爲什麼使用這個:jQuery的 - 尋找具有多個HTML標記的元素在裏面

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

我得到這個(我在Mozilla Firefox的錯誤控制檯除外):

Error: uncaught exception: Syntax error, unrecognized expression: [type=checkbox,name=timeperiod] 

是不是可能搜索具有多個屬性的元素並且它的值?

請解釋並解決我的問題。 :)

回答

9

是的,是這樣的:

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

注意,這也是一個有效的CSS選擇器。

+2

增加了一個答案,但你的更正確,因此我刪除了我的。 – Phliplip

+1

我會在大約11分鐘內接受你的答案......非常感謝你的狗! – metaforce