Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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, 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. :)

like image 885
metaforce Avatar asked Jan 19 '23 08:01

metaforce


1 Answers

Yes, in this way:

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

Note that this is also a valid CSS selector.

like image 171
Alessandro Vendruscolo Avatar answered Jan 29 '23 08:01

Alessandro Vendruscolo