【问题标题】:Access div id from jstl core tag?从 jstl 核心标签访问 div id?
【发布时间】:2016-08-01 10:48:03
【问题描述】:

我有一个 div 标签,样式为 none,id 为 ack。在 if 核心标签中,我需要访问 div id 并需要显示消息。

<body>
<div class="alert alert-success" id="ack"
                    style="display: none" align="center">
                </div>

<c:if test="${LegacyDataForm.petDetails ne null}">
//how to access div id from here
</c:if>
</body>

【问题讨论】:

    标签: jquery html jsp jstl


    【解决方案1】:

    你可以像下面这样:

    <body>
    <div class="alert alert-success" id="ack" style="display: none" align="center">
    </div>
    
    <c:if test="${LegacyDataForm.petDetails ne null}">
    <script>
    //how to access div id from here
    var myDiv = document.getElementById("ack");
    myDiv.style.display = "block";
    myDiv.innerHTML = "My message!";
    </script> 
    </c:if>
    </body>
    

    如果你已经使用过 jquery,你可以使用它。

    【讨论】:

      猜你喜欢
      • 2018-12-21
      • 2017-02-18
      • 2020-12-20
      • 1970-01-01
      • 2013-01-22
      • 2020-04-08
      • 2011-07-03
      • 1970-01-01
      • 2013-12-16
      相关资源
      最近更新 更多