选中checkbox,div出现,当不选中checkbok,div处于隐藏状态
一下是我自己的代码
我的jq应该写错了,但是查了很多都展示不出来
你第二张图片 input type="checkbox" name前面的分号去掉试试
<div class="c1"> 资产管理信息
<input type="checkbox" name="group1"value="yes" onclick="show()">
如输入中心固定资产请勾选
</div>
<div class="layui-form-item" style="display:none" id="zhongxin">
<table>
<tr>
<td style="border: 1px solid red">
<label class="layui-form-label"><p style="font-weight: bold;">资产编号</p></label>
<div class="layui-input-block">
<input type="text" name="country" lay-verify="Country" autocomplete="off"
class="layui-input" id="country" style="width: 180px; height: 25px;margin-top: 5px">
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
<script th:src="@{/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<SCRIPT>
layui.use('form',function () {
var form=layui.form;
form.render();
});
function show() {
var id=document.getElementById("zhongxin");
if(id=="none"){
$("#zhongxin").display="block"
}else {
$("#zhongxin").display="none"
}
}
</SCRIPT>
function show() {
var div = document.getElementById("zhongxin");
if (div.style.display == "none") {
div.style.display = "block";
} else {
div.style.display = "none";
}
}