开始使用 文档 演示/教程 独立组件 社区
全部分类 实体操作 脚本控件

复选框控件

  用于前端,只需要绑定对象即可的实现同时选中多项样式精简的基础控件。添加选中与取消选中事件可实现选择或取消后的操作。

CheckBox()
html代码

<head>

    <title></title>

    <link href="/_css/common.css" rel="stylesheet" type="text/css" />

    <script src="/_js/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script src="/_js/Valid.js" type="text/javascript"></script>

    <script src="download.js" type="text/javascript"></script>

</head>

<body>

<div class="com_table">

   <b class="combox" _txt="1"></b>

   <b class="combox" _txt="2"></b>

   <b class="combox" _txt="3"></b>

</div>

</body>

init()

初始化对象

示例:

$(document).ready(function () {
   $('.com_table .combox').each(function (i, item) {
      var checkbox = new CheckBox();
      checkbox.obj = $(this);
      checkbox.init();
   })
})

展示效果:

click_callback()

点击回调事件

示例:

$('.com_table .combox').each(function (i, item) {
   var checkbox = new CheckBox();
   checkbox.obj = $(this);
   //已选中该项
   checkbox.click_callback = function () {
      alert("已选中该项");
   }
   checkbox.init();
})

展示效果:

click_cancel()

取消选择事件

示例:

$('.com_table .combox').each(function (i, item) {
   var checkbox = new CheckBox();
   checkbox.obj = combox;
   //取消事件
   checkbox.click_cancel = function () {
      alert("已取消选择");
   }
   checkbox.init();
})

展示效果:

开始使用| 文档| 演示/教程| 独立组件| 社区 闽ICP备11018153号-5 Copyright © 2016 - 2017 tiaoceng.com All Rights Reserved