简体   繁体   English

检查是否在特定div中填充了任何字段

[英]Check whether any field is filled in a specific div

I have 10 div tags in my form, in each div there are 5 select boxes. 我的表单中有10个div标签,每个div中有5个选择框。 For example we take first div which contains 5 select boxes, here I want to check whether any 1 of the 5 select boxes is selected or not. 例如,我们以包含5个选择框的first div为例,在这里我要检查5个选择框中的任何一个是否被选中。

If any one selected I need to display some links in my page, if nothing is selected I need to hide the links. 如果选择了任何一个,我需要在页面中显示一些链接,如果未选择任何内容,则需要隐藏这些链接。

Thanks. 谢谢。

Using: 使用方法:

// Detect if a <select> has a value other than 0
function isSelected(){
    $('select').each(function(){
        if($(this).val() != '0'){
            return true;
        }
    });

    return false;
}

// Usage
if(isSelected()){
    // Do something
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM