Home > Article > Web Front-end > How to determine whether the CheckBox selected is empty
What I bring to you this time is how to determine whether the CheckBox selected is empty in JS. Here is a practical column for everyone to analyze.
var chk_value = [];//定义一个数组 //name是CheckBox的name属性定义的名称 $('input[name="time"]:checked').each(function () { chk_value.push($(this).val()); }); if (chk_value.length < 1) { alert("CheckBox选项为空") return false; } alert(chk_value );
I believe you have mastered the method after reading the above introduction. For more exciting information, please pay attention to php Chinese website Other related articles!
Related reading:
Implementation steps for PHP cache optimization using memcached and xcache
Asynchronous synchronization in the use of AJAX How to implement the request
How to download and install nodejs
The above is the detailed content of How to determine whether the CheckBox selected is empty. For more information, please follow other related articles on the PHP Chinese website!