My HTML looks like and js looks like this:
<div class="container"></div>
var html = "<div class="error">hello</div>";
$(".container").append( $(html) );
Problem is that I don’t clear the html inside the div with class=container first, so I keep appending messages to that area.
How can I clear anything inside of the div class=”container” first and THEN append my ‘html’ div?
Assuming you mean to ‘replace’ what is in your div, I think what you need to use is:
A more jQueryish way to do it would be:
That has the added benefit of giving you a reference to the error div.