jquery获取空文本框的个数HTML codediv idcheckinput name typetext /input name type
jquery获取空文本框的个数
- HTML code
<div id="check"><input name="" type="text" /><input name="" type="text" /><input name="" type="text" /><input name="" type="text" /><input name="" type="text" /><a id="btn">获取</a></div>
- JScript code
function chk(){ $("#btn").click(function(){ var Num = $("#check input").length })}突然间脑子好像短路,竟然不知道怎么写。。。 哪位帮帮忙吧
[解决办法]
var num = 0;
$("#check input").each(function() {
if (!$(this).val()) {
num++;
}
});
或
var num = $("#check input").filter(function() {
return !$(this).val();
});
[解决办法]
