Home  >  Article  >  Web Front-end  >  How to determine whether the CheckBox selected is empty

How to determine whether the CheckBox selected is empty

php中世界最好的语言
php中世界最好的语言Original
2017-12-30 17:59:152654browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn