2 回答

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊
html
<form>
<input type="text" value="">
<input type="text" value="">
<input type="text" value="">
<input type="text" value="">
<input type="text" value="">
<input type="button" value="提交">
</form>
js//主要是用了 ES5 的 every 方法,都滿足條件返回 true,否則返回 false
$(document).ready(function() {
$("input[type=button]").click(function(e) {
let isAllEmpty = $("input[type=text]").toArray().every(function(input) {
return input.value === '';
});
if (isAllEmpty) {
alert('都為空');
}
});
});
添加回答
舉報(bào)