Layui表格头部表单筛选条件过多时的折叠与展开效果实现
-折叠状态效果图:
-展开状态效果图:
具体实现代码:
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">查询发送记录</div>
<div class="layui-card-body">
<form class="layui-form" action="" id="search_form">
<div class="layui-form-item">
<div class="layui-fluid">
<div class="layui-row">
<div class="layui-col-xs3">
<div class="layui-inline">
<label class="layui-form-label">开始时间</label>
<div class="layui-input-inline">
<input type="text" name="sdate" class="layui-input" id="sdate" placeholder="请选择开始时间">
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-inline">
<label class="layui-form-label">结束时间</label>
<div class="layui-input-inline">
<input type="text" name="edate" class="layui-input" id="edate" placeholder="请选择结束时间">
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-inline">
<label class="layui-form-label">短信内容</label>
<div class="layui-input-inline">
<input type="text" name="content" class="layui-input" id="content" placeholder="请输入短信内容">
</div>
</div>
</div>
<div class="more-container">
<div class="layui-col-xs3">
<div class="layui-inline">
<label class="layui-form-label">手机号码</label>
<div class="layui-input-inline">
<input type="text" name="mobile" class="layui-input" id="mobile" placeholder="请输入手机号码">
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-inline">
<label class="layui-form-label">提交人</label>
<div class="layui-input-inline">
<input type="text" name="user" class="layui-input" id="user" placeholder="请输入提交人">
</div>
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-inline">
<div class="layui-input-inline">
<button class="layui-btn" lay-submit lay-filter="fsjl"><i class="layui-icon layui-icon-search"></i>查询</button>
<button type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-refresh"></i>重置</button>
<button class="layui-btn layui-btn-normal more-btn" lay-filter="more"><i class="layui-icon layui-icon-addition"></i>展开</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script>
$(".more-btn").click(function () {
if ($(".more-container").is(":hidden")) {
$(".more-container").show(); //如果元素为隐藏,则将它显现
$(".more-btn").html('<i class="layui-icon layui-icon-subtraction"></i>收起')
} else {
$(".more-container").hide(); //如果元素为显现,则将其隐藏
$(".more-btn").html('<i class="layui-icon layui-icon-addition"></i>展开')
}
return false;
})
</script>
<style>
.layui-form-label {
padding: 9px 0px;
text-align: center;
}
.layui-form-item .layui-inline {
margin-bottom: 14px;
}
.layui-form-item .layui-input-inline {
width: auto !important;
}
.layui-btn{
padding:0 10px;
}
.more-container {
display: none;
}
</style>