This time I will bring you the use of checkbox to operate layui tables, and what are the precautions for using checkbox to operate layui tables. The following is a practical case, let's take a look.
In the previous version, the default1. Layui version number is v1.0.9 rls version (currently the latest version)
<span style="white-space:pre;"> </span><p class="layui-form"> <table class="layui-table"> <thead> <tr> <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th> <th>人物</th> <th>民族</th> <th>出场时间</th> <th>格言</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" name="" lay-skin="primary"></td> <td>贤心</td> <td>汉族</td> <td>1989-10-14</td> <td>人生似修行</td> </tr> <tr> <td><input type="checkbox" name="" lay-skin="primary"></td> <td>张爱玲</td> <td>汉族</td> <td>1920-09-30</td> <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td> </tr> </tbody> </table> </p> <script type="text/javascript" src="plugins/layui/lay/dest/layui.all.js"></script> <script type="text/javascript"> var $ = layui.jquery, form = layui.form(); //全选 form.on('checkbox(allChoose)', function(data){ var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]'); child.each(function(index, item){ item.checked = data.elem.checked; }); form.render('checkbox'); }); </script>
2. Version Versions before v1.0.9 rls need to update several files
(a)layui.all.js file in layui\lay\dest(b ) The form.js file in layui\lay\modules
(c) The layui.css file in layui\cssChange the above three files from the latest By overwriting the original version in the version, you can easily implement the checkbox style. I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:How $set updates the array in vue.js
How does JQuery select the value specified in the select component
The above is the detailed content of Use checkbox to operate layui tables. For more information, please follow other related articles on the PHP Chinese website!