tags:

views:

57

answers:

2

How do i loop thru all dropdown boxes in JQuery?

A: 

something like this should do the trick

$("select").each(function() {
    //do something with the select $(this) will give you the select element
});
Marek Karbarz
or just, y'know, `$('select')`
Mark
I realized my mistake, input didn't even work
Marek Karbarz
Hos do I loop thru in multiple divs?Can I do $('#mydivname').find('select').each(function(){});??
Greens
are you looking for something like this $("#mydiv select").each(...) ?
Marek Karbarz
+1  A: 

$("select") will include all the combo boxes too. To just get the drop down menus, use this:

$("select:not([size])")

To answer your other question:

How do I loop thru in multiple divs? Can I do $('#mydivname').find('select').each(function(){ }); ??

$('#mydivname select:not[size]').each(...)
nickf
Excellent use of attributes to narrow down to ONLY dropdowns
Kevin Peno