博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery和bootstrap获取checkbox选中的多行数据
阅读量:6632 次
发布时间:2019-06-25

本文共 7028 字,大约阅读时间需要 23 分钟。

在项目中,经常遇到,于是整理

引用bootstrap的js和css

代码解释:

$("#dgFlowList").find(":checkbox:checked").each(function(){

  var val = $(this).parents("tr").text();
  data.push(val);
});

 

代码:

1  2  3     多选 4     
5
6 7 8 9 40 41 42 43
45
46
47
48
49
50
51
52
55
56
57
58
59
60
63
64
65
66
67
68
71
72
73
74
75
76
79
80
81
82
83
84
87
88
流程名称 表单名称 操作
请假单1 请假单 53 删除54
请假单2 请假单 61 删除62
请假单3 请假单 69 删除70
请假单4 请假单 77 删除78
请假单5 请假单 85 删除86
89
90
91
92 93

app.js代码,是为notify写的,于功能没有多大的关系

1 /**  2  * Notify Addon definition as jQuery plugin  3  * Adapted version to work with Bootstrap classes  4  * More information http://getuikit.com/docs/addons_notify.html  5  */  6   7 (function ($, window, document) {  8   9     var containers = {}, 10         messages = {}, 11  12         notify = function (options) { 13  14             if ($.type(options) == 'string') { 15                 options = {message: options}; 16             } 17  18             if (arguments[1]) { 19                 options = $.extend(options, $.type(arguments[1]) == 'string' ? {status: arguments[1]} : arguments[1]); 20             } 21  22             return (new Message(options)).show(); 23         }, 24         closeAll = function (group, instantly) { 25             if (group) { 26                 for (var id in messages) { 27                     if (group === messages[id].group) messages[id].close(instantly); 28                 } 29             } else { 30                 for (var id in messages) { 31                     messages[id].close(instantly); 32                 } 33             } 34         }; 35  36     var Message = function (options) { 37  38         var $this = this; 39  40         this.options = $.extend({}, Message.defaults, options); 41  42         this.uuid = "ID" + (new Date().getTime()) + "RAND" + (Math.ceil(Math.random() * 100000)); 43         this.element = $([ 44             // alert-dismissable enables bs close icon 45             '
', 46 '
×', 47 '
' + this.options.message + '
', 48 '
' 49 50 ].join('')).data("notifyMessage", this); 51 52 // status 53 if (this.options.status) { 54 this.element.addClass('alert alert-' + this.options.status); 55 this.currentstatus = this.options.status; 56 } 57 58 this.group = this.options.group; 59 60 messages[this.uuid] = this; 61 62 if (!containers[this.options.pos]) { 63 containers[this.options.pos] = $('
').appendTo('body').on("click", ".uk-notify-message", function () { 64 $(this).data("notifyMessage").close(); 65 }); 66 } 67 }; 68 69 70 $.extend(Message.prototype, { 71 72 uuid: false, 73 element: false, 74 timout: false, 75 currentstatus: "", 76 group: false, 77 78 show: function () { 79 80 if (this.element.is(":visible")) return; 81 82 var $this = this; 83 84 containers[this.options.pos].show().prepend(this.element); 85 86 var marginbottom = parseInt(this.element.css("margin-bottom"), 10); 87 88 this.element.css({ 89 "opacity": 0, 90 "margin-top": -1 * this.element.outerHeight(), 91 "margin-bottom": 0 92 }).animate({"opacity": 1, "margin-top": 0, "margin-bottom": marginbottom}, function () { 93 94 if ($this.options.timeout) { 95 96 var closefn = function () { 97 $this.close(); 98 }; 99 100 $this.timeout = setTimeout(closefn, $this.options.timeout);101 102 $this.element.hover(103 function () {104 clearTimeout($this.timeout);105 },106 function () {107 $this.timeout = setTimeout(closefn, $this.options.timeout);108 }109 );110 }111 112 });113 114 return this;115 },116 117 close: function (instantly) {118 119 var $this = this,120 finalize = function () {121 $this.element.remove();122 123 if (!containers[$this.options.pos].children().length) {124 containers[$this.options.pos].hide();125 }126 127 delete messages[$this.uuid];128 };129 130 if (this.timeout) clearTimeout(this.timeout);131 132 if (instantly) {133 finalize();134 } else {135 this.element.animate({136 "opacity": 0,137 "margin-top": -1 * this.element.outerHeight(),138 "margin-bottom": 0139 }, function () {140 finalize();141 });142 }143 },144 145 content: function (html) {146 147 var container = this.element.find(">div");148 149 if (!html) {150 return container.html();151 }152 153 container.html(html);154 155 return this;156 },157 158 status: function (status) {159 160 if (!status) {161 return this.currentstatus;162 }163 164 this.element.removeClass('alert alert-' + this.currentstatus).addClass('alert alert-' + status);165 166 this.currentstatus = status;167 168 return this;169 }170 });171 172 Message.defaults = {173 message: "",174 status: "normal",175 timeout: 5000,176 group: null,177 pos: 'top-center'178 };179 180 181 $["notify"] = notify;182 $["notify"].message = Message;183 $["notify"].closeAll = closeAll;184 185 return notify;186 187 }(jQuery, window, document));
View Code

 

 

转载于:https://www.cnblogs.com/invban/p/8568980.html

你可能感兴趣的文章