Question: I have some code. When it runs correctly, I create a success message and use prependTo in order to display it on the screen. The problem is that when the user does their successful action twice, I end up with two success messages.

Is there a way to overwrite my success message. Here is how I currently handle it in my code:

```
  $((is_error ? "<p class=' alert alert-error'>"+message+"</p>)" : "<p class=' alert alert-success'>"+message+"</p>")).prependTo("#feedback-container");

```

Thanks!

Answer: 
You can use simply this :

```
$("#feedback-container").html((is_error ? "<p class=' alert alert-error'>"+message+"</p>)" : "<p class=' alert alert-success'>"+message+"</p>"));

```

So the entire content of your container is replaced.
By definition prependTo will "inserted at the beginning of the element(s) specified by this parameter." In other words, it will **insert** but not **replace**.

What you are looking for is most likely the **html** method that will set the innerHTML of the matched element with the given content: <http://api.jquery.com/html/>

The usage of **html()** is slightly different to **prependTo()** but conceptually the same:

```
 $("#feedback-container").html((is_error ? "<p class=' alert alert-error'>"+message+"</p>)" : "<p class=' alert alert-success'>"+message+"</p>"));

```