[1].[代码] checkbox 选中、取值处理 跳至 [1]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/****处理checkbox 配合jquery,layer 使用****/
var handleCheckbox;
 
function HandleCheckbox(className) {
    this.className = className;
};
 
//全选
HandleCheckbox.prototype.Select = function() {
    $("[class='" + this.className + "']:checkbox").prop("checked", true);
};
 
//取消全选
HandleCheckbox.prototype.unSelect = function() {
    $("[class='" + this.className + "']:checkbox").removeAttr("checked");
};
 
//获取 checkbox 实例
HandleCheckbox.prototype.GetInstance = function() {
 
    var Instances = $("[class='" + this.className + "']:checkbox:checked");
    if (Instances.length > 0) {
        //console.log($(Instances[0]).attr("extend"));
        return Instances[0];
    }
    else {
        layer.msg('没有选择数据');
    }
};
 
//获取选中的值
HandleCheckbox.prototype.GetValues = function() {
 
    var result = new Array();
    $("[class='" + this.className + "']:checkbox").each(function() {
        if ($(this).is(":checked")) {
            result.push($(this).attr("value"));
        }
    });
    console.log(result);
    return result.join(",");
};
 
//检查是否选中数据
HandleCheckbox.prototype.GetSingleValue = function() {
 
    var args = this.GetValues().split(",");
    if (args == "" || args.length == 0) {
        layer.msg('没有选择数据');
        return false;
    }
 
    if (args.length > 1) {
        layer.msg('请选择一条数据进行操作');
        return false;
    }
    return args[0];
};
 
(function() {
 
    handleCheckbox = new HandleCheckbox("zz");
 
})();
 
---------调用示例---------
<a href="#" onclick="handleCheckbox.Select();">全选</a>

checkbox 选中、取值处理的更多相关文章

  1. Jquery操作复选框(CheckBox)的取值赋值实现代码

    赋值 复选框 CheckBox 遍历 取值  1. 获取单个checkbox选中项(三种写法): $("input:checkbox:checked").val() 或者 $(&q ...

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

    webform中获取repeat控件列表下的checkbox选中的值: 码农上代码: public static string getSelectedIDs(Repeater Rpt_) { stri ...

  3. jquery操作select下拉框的多种方法(选中,取值,赋值等)

    Query获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); //为Sel ...

  4. angular raido checkbox select取值

    radio {{modelName}} <div class="radio disIB"> <label class="i-checks"&g ...

  5. jquery取checkbox选中的值

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  6. jquery 取指定class下的input checkbox选中的值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. jQuery之获取checkbox选中的值

    <mce:script src="jquery.js" mce_src="jquery.js"></mce:script><!-- ...

  8. 作品第一课----获取批量checkbox选中的值

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. jQuery radio|checkbox的取值与赋值

    文章简单即是美[我说的是技术博客] |--radio   |--checkbox   参考: http://blog.csdn.net/gd2008/article/details/6951208 h ...

  10. checkbox 选中获取值

    1:jsp 页面 从页面获取checkbox 的值传到后台 <div id="divCheckbox" class="hide"> <tr&g ...

随机推荐

  1. 浏览器html页面乱码问题分析

    直接访问某html文件,浏览器显示编码是正常的,页面通过<meta charset="UTF-8">指定了编码方式,该文件存储编码也是utf8. 通过配置的org.sp ...

  2. 类似qq的浮动窗口 ,随着滚轴的滚动,始终处于屏幕的中间(能看到运动的过程)

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. Add two numbers [LeetCode]

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  4. Teach Yourself Programming in Ten Years

    Teach Yourself Programming in Ten Years——用十年教会自己编程 作者:Peter Norvig 译者:刘海粟 本文原文为:http://norvig.com/21 ...

  5. 对已经发布订阅的sqlserver进行修改-添加新的表

    1.以服务器名称连接数据库 2.找到复制-本地发布-对应的数据库发布订阅-右键属性-选择项目-选择新增的表(没有看到,注意取消右侧的仅显示列表已选择的项目) 3.然后重新初始化所有订阅 4.如果出现“ ...

  6. Leetcode 155 Min Stack 小顶堆+栈,优先队列实现 难度:0

    https://leetcode.com/problems/min-stack/ #include <vector> #include <queue> #include < ...

  7. IBatis.Net XML文件配置

    一.添加Provider.config <?xml version="1.0" encoding="utf-8"?> <providers x ...

  8. debug实战:Unmanaged High Memory非托管高内存

    最近又监控到一个高内存的问题,周五下班把系统打开,周末2天没关,周一来看已经涨到5.2G,这次与以往不同,不是.net的内存泄漏,而是非托管引起的. 1. 抓dump,确定高内存的类型 //dump有 ...

  9. 解决 iOS7 通过tag 找不到 UITableViewCell 的子控件

    当iOS7问世,程序的世界就混乱了,以前良好的程序,现在是一塌糊涂,于是只能把问题一个一个攻破. 由于项目当中需要每个cell显示数目不同的图片,于是我在每个cell 赋值之前,通过一下方法把cell ...

  10. realestate.cei.gov.cn

    using AnfleCrawler.Common; using System; using System.Collections.Concurrent; using System.Collectio ...