input框遍历是否为空

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了input框遍历是否为空相关的知识,希望对你有一定的参考价值。

很简单的一个方法,这是我自己做的遍历项目中的实例,不为空时,按钮变色,空时按钮灰色

//input框值不为空时
    $(‘input‘).on(‘input propertychange‘, function() {
        if(($.trim($(‘#cname‘).val()) !== "") && ($.trim($(‘#cpass1‘).val()) !== "") && ($.trim($(‘#cpass‘).val()) !== "")){
            $(".submit").css("background-color","#5fcdd7");
        } else {
            $(".submit").css("background-color","#d1d1d1");
        }
    });

以上是关于input框遍历是否为空的主要内容,如果未能解决你的问题,请参考以下文章