社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Ashique

Ashique 最近创建的主题
Ashique 最近回复了
7 年前
回复了 Ashique 创建的主题 » jquery count具有值的输入字段数

你在你发现但使用相同的 领域 包含所有字段以查找值的变量。相反你必须这么做 这 -

$('.input').keyup(function () {

    var field = $(this).parent().find('.input');
    var count = 0;

    $(field).each(function (i) {
        var len = $(this).val().length;     
        if (len > 0 ) {
            count++;
        }
    });

  alert(count);

});

小提琴: http://jsfiddle.net/ashhaq12345/yxrwdkfL/3/