ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## table表格全选: ~~~ $(function () { /*全选*/ $("table thead th input:checkbox").on("click", function () { $(this).closest("table").find("tr > td:first-child input:checkbox").prop("checked", $("table thead th input:checkbox").prop("checked")); }); }); ~~~ 使用layui, ~~~ layui.define(['jquery', 'form', 'layer', 'element'], function (exports) { var $ = layui.jquery, form = layui.form, layer = layui.layer, element = layui.element; var menu = []; var curMenu; /* 监听状态设置开关 */ form.on('switch(switchStatus)', function (data) { var that = $(this), status = 0; if (!that.attr('data-href')) { layer.msg('请设置data-href参数'); return false; } if (this.checked) { status = 1; } $.get(that.attr('data-href'), { val: status }, function (res) { layer.msg(res.msg); if (res.code == 0) { that.trigger('click'); form.render('checkbox'); } }); }); /* TR数据行删除 */ $('.j-tr-del').click(function () { var that = $(this), href = !that.attr('data-href') ? that.attr('href') : that.attr('data-href'); layer.confirm('删除之后无法恢复,您确定要删除吗?', {}, function (index) { if (!href) { layer.msg('请设置data-href参数'); return false; } $.get(href, function (res) { layer.msg(res.msg); if (res.code == 1) { that.parents('tr').remove(); that.parents('.tr').remove(); } }); layer.close(index); }); return false; }); }); ~~~