问题
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