
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>测试 - layui</title>
<link rel="stylesheet" href="layui/css/layui.css">
<style>
.layui-table-box.lastbackground table tbody>tr:nth-last-child(1) {
background: #b9e7e3;
color: #fff;
}
</style>
</head>
<body>
<button id="btn" class="layui-button">增加</button>
<button id="btn2" class="layui-button">取消</button>
<table id="demo" lay-filter="test"></table>
</div>
<script src="layui/layui.js"></script>
<script>
var $ = layui.jquery;
layui.use('table', function () {
var table = layui.table;
var $ = layui.jquery;
$("#btn").click(function () {
data.push({
id: 1,
username: '111'
})
table.reload('demo', {
done: function () {
$('.layui-table-box').addClass('lastbackground')
}
});
})
$("#btn2").click(function () {
data.splice(-1, 1)
table.reload('demo', {
done: function () {
$('.layui-table-box').removeClass('lastbackground')
}
});
})
var table = layui.table;
var data = [{
id: 1,
username: 'username'
}]
table.render({
elem: '#demo'
, height: 312
, data: data
, page: true
, cols: [[
{ field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
, { field: 'username', title: '用户名', width: 80 }
, { field: 'sex', title: '性别', width: 80, sort: true }
, { field: 'city', title: '城市', width: 80 }
, { field: 'sign', title: '签名', width: 177 }
, { field: 'experience', title: '积分', width: 80, sort: true }
, { field: 'score', title: '评分', width: 80, sort: true }
, { field: 'classify', title: '职业', width: 80 }
, { field: 'words', title: '字数', width: 135, sort: true }
]]
});
});
</script>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探