zoukankan      html  css  js  c++  java
  • js-读取复选框

    js:

    var obj = document.getElementsByName("yk");
        var check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }

    jquery:

    $(document).ready(function(){
        var checked = [];
        $("#submitButton").click(function(){
            $('input:checkbox:checked').each(function() {
                checked.push($(this).val());
            });
            alert(checked);
        });
    });
    $(document).ready(function(){
        var checked = [];
        $("#submitButton").click(function(){
            $('input:checkbox:checked').each(function() {
                checked.push($(this).val());
            });
            alert(checked);
        });
    });
  • 相关阅读:
    Python学习-day10
    python学习-day9
    Python学习-day8
    Python学习-day7
    Python学习-day6
    Django2
    Django讲解
    JQuery讲解
    前端Day2
    前端Day1
  • 原文地址:https://www.cnblogs.com/hwaggLee/p/5876891.html
Copyright © 2011-2022 走看看