jQuery – Looping through a collection of dropdowns

I have a collection of dropdowns dynamically generated by server code. Each of them have same set of values. My goal is to loop through all of them and see if at least one of the dropdowns is set to a specific value.

The id of each dropdown looks like:

Here’s a jQuery notation to loop through them all and check the selected value to set a global flag if a result is found.

var hosted = false;
	if ($(this).val() == 'H') {
		hosted = true;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s