从页面获取多个相同name的input文本框的值的方法

xiaoxiao2021-02-28  71

第一种用each遍历

$("input[name='productNames']").each(function(){

if( $(this).val().trim() == '') {   layer.tips('请填写产品名称!', this,{ time: 3000, tips: 2, tipsMore: true

});

                        scrollOffset($("#productNames").offset(),300);

flag=false; return;  }

});

第二种用for循环

var pname =$("input[name='productNames']"); for ( var i = 0; i < pname.length; i++) { if(pname[i].value==""){ layer.tips('请填写产品名称!', pname[i],{ time: 3000, tips: 2, tipsMore: true }); scrollOffset($("#productNames").offset(),300); flag=false; return;  } }

转载请注明原文地址: https://www.6miu.com/read-64553.html

最新回复(0)