I'm trying to get all select elements in a given div, even though they have different class names. It looks like this:
<div id="mydiv">
<select class="myclass">...</select>
<select class="myotherclass">...</select>
</div>
I'd like to get all the selects with myclass
or myotherclass
. I've tried several ways but can't get it right.
I've tried variations of the following:
$.each($('[#mydiv select.myclass][#mydiv select.myotherclass]'), function(){ // handle stuff
$.each($('#mydiv select.myclass select.myotherclass'), function(){ // handle stuff
$.each($('#mydiv select.myclass myotherclass'), function(){ // handle stuff
and others, but I can't seem to get both selects into my element selection.
也许
$('#mydiv select.myclass, #mydiv select.myotherclass')
$.each($("#mydiv .myclass, #mydiv .myotherclass"), function(){ // handle stuff });
I think it works with
$('#mydiv select.myclass, #mydiv select.myotherclass')
as in Css Selectors
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.