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

jQuery implements statistics on the number of selected check boxes_jquery

WBOY
WBOYOriginal
2016-05-16 16:30:281558browse

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.

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