jQuery 如何判断text文本框是否为空?

2025-05-14 13:45:37
推荐回答(2个)
回答1:

根据id获取1个:alert($("#id").val()=='');
获取全部:
$("input[type=text]").each(function(){
if($(this).val()=='') alert('第'+($(this).index()+1)+'个文本框为空');
});

回答2:

var checkTextInput = function(id){
return !!$(id).val();

};