Home > Web Front-end > JS Tutorial > jQuery implements statistics on the number of selected check boxes_jquery

jQuery implements statistics on the number of selected check boxes_jquery

WBOY
Release: 2016-05-16 16:30:28
Original
1613 people have browsed it

The code is very brief and the function is very simple, but it is very practical. I will not explain it in detail here and just go to the code

jQuery code:

Copy code The code is as follows:

function countNum(){
                  //alert($('input[name=check]:checked').length);
        var arrays = new Array();
            var items = document.getElementsByName("check");
              for(var i=0;i If(items[i].checked){
                       arrays.push(items[i].value);
                                                                                                                  }
             alert(arrays.length);
}

HTML code:

Copy code The code is as follows:





Partners in the project who have the same needs can refer to it. If you have a better way, please contact me.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template