如何使用javascript隐藏jsp文件中的元素
<li><label>Email:</label> <input type='text' name='username'
id="forgot_username" /></li>
<li><label> </label> <input type="submit"
id="forgot_btn" value="Send Reminder" class="btn"></li>
我的 jsp 中有上面的文本框和按钮。而下面的情况,我想要的是当这种情况发生时,上面的文本框和按钮应该隐藏我该怎么做。
<c:if test="${param.message == 3}">
<span class="error"><font color="red"> Email does not match</font></span>
</c:if>
<li><label>Email:</label> <input type='text' name='username'
id="forgot_username" /></li>
<li><label> </label> <input type="submit"
id="forgot_btn" value="Send Reminder" class="btn"></li>
I have above text box and button in my jsp. and the below condition, what i want is when this condition occur , above text box and button should hide how can i do it.
<c:if test="${param.message == 3}">
<span class="error"><font color="red"> Email does not match</font></span>
</c:if>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在第一个代码周围放置 div 标签,如下所示:
然后您可以像这样隐藏:
You should put div tags around the first code like this:
And then you can hide like this:
为什么不能将这些
元素放入相同的构造中?
如果你不能把这些元素放在一起并且不想重复条件,你总是可以定义一个新变量:
这样即使客户端有JS,这些
也会被隐藏禁用,或任何类型的 JS 问题。
Why can't you put those
<li>
elements inside an identical construct?If you can't put those elements together and don't want to repeat the condition, you can always define a new variable:
This way those
<li>
will be hidden even if the client has JS disabled, or any kind of JS problem.