$('#button').click(function() {
if ($('select[name^="dropdown_"][value="Test 1"]').length) {
alert("Found.");
}
});
I have 6 dropdown menus on a page. I am trying to check if a certain value is selected in one of them. The above isn’t doing it, although it looks right. What am I missing here?
Use this selector:
Though I would suggest perhaps using a class name for those option values so you can get at them more efficiently like:
Or, at the very least apply a class name on the selects