可以使用 JSF 删除组件 HTML 内容
您好,我有这样的 HTML 内容:
<div id="j_idt33:summary">
<ul id="j_idt33:summary2" class="summary">
<li style="margin-right: 85%; Color:red;">Some Error Message.</li>
</ul>
</div>
我希望当用户单击按钮时清除该 DIV 的所有内容以获得如下输出:
<div id="j_idt33:summary">
</div>
是否可以使用 JSF 执行类似的操作?或者用 JavaScript 来实现?你们有什么建议?
请指教。
hi i have HTML content like:
<div id="j_idt33:summary">
<ul id="j_idt33:summary2" class="summary">
<li style="margin-right: 85%; Color:red;">Some Error Message.</li>
</ul>
</div>
i want when the user click on a button to clear all the contents of that DIV to get output like:
<div id="j_idt33:summary">
</div>
is it possible to do something like that with JSF ? or achieve that with JavaScript ? what do you suggest guys ?
please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 JavaScript 方面,你可以这样做:
或者当你使用 jQuery 时:
你只需要提供父
NamingContainer
组件,它具有id="j_idt33"< 的 HTML 表示形式。 /code> (我猜它是
)一个固定的 ID,以便代码更加健壮。生成的 ID 可能会随着 JSF impl/version 和组件树的状态而变化。In JavaScript side, you could do something like this:
Or when you're using jQuery:
You only need to give the parent
NamingContainer
compnent which has a HTML representation withid="j_idt33"
(I guess it's the<h:form>
) a fixed ID so that the code is more robust. The generated ID may change with JSF impl/version and the component tree's state.