多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 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; }); }); ~~~