可以使用 JSF 删除组件 HTML 内容

发布于 2024-12-18 07:00:39 字数 426 浏览 2 评论 0原文

您好,我有这样的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

享受孤独 2024-12-25 07:00:39

在 JavaScript 方面,你可以这样做:

document.getElementById("j_idt33:summary").innerHTML = "";

或者当你使用 jQuery 时:

$("#j_idt33\\:summary").empty();

你只需要提供父 NamingContainer 组件,它具有 id="j_idt33"< 的 HTML 表示形式。 /code> (我猜它是 )一个固定的 ID,以便代码更加健壮。生成的 ID 可能会随着 JSF impl/version 和组件树的状态而变化。

In JavaScript side, you could do something like this:

document.getElementById("j_idt33:summary").innerHTML = "";

Or when you're using jQuery:

$("#j_idt33\\:summary").empty();

You only need to give the parent NamingContainer compnent which has a HTML representation with id="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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文