[英]HTML - DIV not hiding
I have a project based in Spring Web model-view-controller (MVC) framework.我有一个基于 Spring Web 模型-视图-控制器 (MVC) 框架的项目。 The version of the Spring Web model-view-controller (MVC) framework is 3.2.8 I have this piece of code in my JSP
Spring Web 模型-视图-控制器 (MVC) 框架的版本是 3.2.8 我的 JSP 中有这段代码
<div class="col-md-12" id="secondSignatoryDivId" >
<table width="100%">
<thead>
<tr>
<th><b>First name</b></th>
<th><b>Last name</b></th>
<th><b>Position</b></th>
<th><b>Title</b></th>
<th><b>Actions</b></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="${deviceForm.device.secondSignatory.firstname}" <c:if test="${readonly}">disabled="disabled"</c:if> class="form-control"/></td>
<td><input type="text" value="${deviceForm.device.secondSignatory.lastname}" <c:if test="${readonly}">disabled="disabled"</c:if> class="form-control"/></td>
<td><input type="text" value="${deviceForm.device.secondSignatory.position}" <c:if test="${readonly}">disabled="disabled"</c:if> class="form-control"/></td>
<td><input type="text" value="${deviceForm.device.secondSignatory.title}" <c:if test="${readonly}">disabled="disabled"</c:if> class="form-control"/></td>
<td>Delete</td>
</tr>
</tbody>
</table>
</div>
<c:if test="${empty applicationForm.application.secondSignatory}">
<script>
alert ('lalalal');
$('#secondSignatoryDivId').hide();
</script>
</c:if>
I see the alert but the div does not hide !我看到警报,但 div 没有隐藏!
You are using jQuery, you should include jQuery on your html file:您正在使用 jQuery,您应该在 html 文件中包含 jQuery:
alert('lalalal'); $('#secondSignatoryDivId').hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="col-md-12" id="secondSignatoryDivId"> <table width="100%"> <thead> <tr> <th><b>First name</b> </th> <th><b>Last name</b> </th> <th><b>Position</b> </th> <th><b>Title</b> </th> <th><b>Actions</b> </th> </tr> </thead> <tbody> <tr> <td> <input type="text" value="${deviceForm.device.secondSignatory.firstname}" <c:if test="${readonly}">disabled="disabled"</c:if>class="form-control"/></td> <td> <input type="text" value="${deviceForm.device.secondSignatory.lastname}" <c:if test="${readonly}">disabled="disabled"</c:if>class="form-control"/></td> <td> <input type="text" value="${deviceForm.device.secondSignatory.position}" <c:if test="${readonly}">disabled="disabled"</c:if>class="form-control"/></td> <td> <input type="text" value="${deviceForm.device.secondSignatory.title}" <c:if test="${readonly}">disabled="disabled"</c:if>class="form-control"/></td> <td>Delete</td> </tr> </tbody> </table> </div>
If it is just for hiding the element then better to do it with css :如果只是为了隐藏元素,那么最好用css来做:
<c:if test="${empty applicationForm.application.secondSignatory}">
<style>
#secondSignatoryDivId.col-md-12 { display:none; }
</style>
</c:if>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.