Is is possible to delete Component HTML Content with JSF

非 Y 不嫁゛ 提交于 2019-12-13 05:19:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8278477/is-is-possible-to-delete-component-html-content-with-jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!