How to find all dropdowns on a page using jQuery

How do I go through all the dropdowns in jQuery?

+4
source share
2 answers

something like this should do the trick

$("select").each(function() { //do something with the select $(this) will give you the select element }); 
+11
source

$("select") will include all relevant fields. To just get the dropdowns, use this:

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

To answer another question:

How do I go through a few divs? Can I do $('#mydivname').find('select').each(function(){ }); ??

 $('#mydivname select:not[size]').each(...) 
+8
source

All Articles