javascript - HTML - DIV 不隐藏

标签 javascript jquery html jsp spring-mvc

我有一个基于 Spring Web 模型- View - Controller (MVC) 框架的项目。 Spring Web模型- View - Controller (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> 

我看到了警报,但 div 没有隐藏!

最佳答案

您正在使用 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>

关于javascript - HTML - DIV 不隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41548029/

相关文章:

jQuery - 函数在 div 单击时运行正常,但在页面加载时运行正常

javascript - 为 1 个 div 执行 JQuery 函数

html - 如何使用实心边框CSS样式

html - chrome 在打印预览时截断页面内容,而其他浏览器则不会

javascript - Angular 2,如何编写自定义 mousedown/touchstart 实现

javascript - 如何跟踪 Marionette.LayoutView 中输入的更改

javascript - Alloy-ui 多个日期选择器将选择发送到其他输入

javascript - 配置angularjs模块发送补丁请求

php - 无法使用 Jquery $().attr 获取循环 PHP 变量的 attr

javascript - 如何将网页向下推以适合顶部栏