开发者

How to loop through all dropdown menus to check if they have a certain selected value?

I asked this question previously: Disabling and Re-Enabling Dynamic Form Elements with JQuery but I feel that I was perhaps asking the wrong question.

Please see this fiddle for an easier way to understand my problem: http://jsfiddle.net/5ubTe/12/

I already have a function to check when the tags drop down is changed and what I am looking t开发者_运维问答o do is to check all dropdowns of the class dropdown and dropdownclone and check if any of their selected values are tags.

If any of them have that value then disable the submit button by calling the function, if none of them have the tags value then enable the submit button for the form to be processed.

Hope that makes sense!

Thanks for any help given.

UPDATE

Latest fiddle: http://jsfiddle.net/5ubTe/14/ but doesn't work... yet.


You should be able to use a selector for this an tranverse the dropdowns to check for the selected options. Then check the length of the result to see if any were matched.

var selected= $('.dropdown, .dropdownclone').find('option[value=tags]:selected');

if(selected.length > 0) {
    disableSubmit();
}
else {
    enableSubmit(); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜