-22 Votes

jQuery: Replace HTML content in DIV

Question by Guest | 2013-12-18 at 22:53

I have a DIV container in my HTML website and I would like to replace the entire content or HTML inside this DIV with another HTML content using jQuery. Can someone tell me how to do this?

0Best Answer0 Votes

Assuming your DIV container has the ID "mydiv" and is looking somehow like this

<div id="mydiv">Some content</div>

you can just use this code to replace the inner HTML of the container with another content:

$("#mydiv").html("<p>Some other content</p>");

More about this, you can find in the tutorial regarding replacing content of an element using pure JavaScript or jQuery.
2013-12-19 at 20:23

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.