$(document).on(\"click\", \".layui-table-body table.layui-table tbody tr\", function () {var index = $(this).attr(\'data-index\');var tableBox = $(this).parents(\'.layui-table-box\');//判断存在固定列if (tableBox.find(\".layui-table-fixed.layui-table-fixed-l\").length > 0) {tableDiv = tableBox.find(\".layui-table-fixed.layui-table-fixed-l\");} else {tableDiv = tableBox.find(\".layui-table-body.layui-table-main\");}var checkCell = tableDiv.find(\"tr[data-index=\" + index + \"]\").find(\"td div.laytable-cell-checkbox div.layui-form-checkbox I\");if (checkCell.length > 0) {checkCell.click();}});//对td的单击事件进行拦截停止,防止事件冒泡再次触发上述的单击事件(Table的单击行事件不会拦截,依然有效)$(document).on(\"click\", \"td div.laytable-cell-checkbox div.layui-form-checkbox\", function (e) {e.stopPropagation(); 阻止事件冒泡});
Layui Table点击行时选中复选框 checkbox — jquery
未经允许不得转载:爱站程序员基地 » Layui Table点击行时选中复选框 checkbox — jquery