js 获取checkbox选中项目

#

//获取选中项
$(‘#submit‘).click(function () {
    var check_list = []
    $("input[name=‘ck‘]:checked").each(function () {
        check_list.push(this.value);
    });
    alert(check_list.join(","));
});

//全选/取消全选
$(‘#all‘).toggle(function () {
    $("input[name=‘ck‘]").attr("checked", ‘true‘);
}, function () {
    $("input[name=‘ck‘]").removeAttr("checked");
});

//反选
$(‘#unselected‘).click(function () {
    $("input[name=‘ck‘]").each(function () {
        if ($(this).attr("checked")) {
            $(this).removeAttr("checked");
        } else {
            $(this).attr("checked", ‘true‘);
        }
    });
});

#

时间: 2024-08-14 20:55:33

js 获取checkbox选中项目的相关文章

js获取checkbox复选框获取选中的选项

js获取checkbox复选框获取选中的选项 分享下javascript获取checkbox 复选框获取选中的选项的方法. 有关javascript 获取checkbox复选框的实例数不胜数.js实现: var form = document.getElementById("form2"); var field = form.elements["test2"]; var option = Dining.getSelectedOption(form, field);

jQuery获取checkbox选中的值

1.问题背景 有几个多选框,选择其中的几个,获取选中的值 2.设计源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>

JQuery 判断checkbox是否选中,checkbox全选,获取checkbox选中值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

js限制checkbox选中个数

今天在做项目时,碰到一个问题,我需要展示多个checkbox复选框,而只能允许最多选6个.调试了老半天,终于出来了,代码如下: <SCRIPT LANGUAGE="JavaScript"> var c=0,limit=6; function doCheck(obj) { obj.checked?c++:c--; if(c>limit){ obj.checked=false; alert("over"); c--; } } </SCRIPT&g

js获取checkbox值的方法

js获取checkbox值的方法.分享给大家供大家参考.具体实现方法如下:<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>js</title> </head> <script language="javascript"> functio

webform开发经验(一):Asp.Net获取Checkbox选中的值

webform中获取repeat控件列表下的checkbox选中的值: 码农上代码: public static string getSelectedIDs(Repeater Rpt_) { string res = string.Empty; foreach (RepeaterItem rtpItem in Rpt_.Items) { HtmlInputCheckBox obj = rtpItem.FindControl("checkbox") as HtmlInputCheckBo

JS获取select选中的值,所有option值

<select name="myselect" id="myselect"> <option value="2042">1--测试二级页面专题</option> <option value="2031">2--2016年浙江省大学生艺术节</option> <option value="1983">3--2016里约奥运图粹</o

Jquery JS 获取 Checkbox 是否选中

正确方法: var isReturned = document.getElementById('cboxReturned').checked; 错误方法: var isReturned = $("#cboxReturned").attr("checked");

js获取鼠标选中的文字

1.获取选中的文字: document.selection.createRange().text; IE9以下使用 window.getSelection().toString(); 其他浏览器使用 $('p').mouseup(function(){ var txt = window.getSelection?window.getSelection():document.selection.createRange().text; alert(txt) ; }) 2.取消处于选中状态的文字: d