sephiith sephiith - 10 months ago 60
Javascript Question

How to remove a div's content with jQuery

How would I go about removing the content inside a div tag with the class


<div class="content"></div>

I would imagine it would be something like:


Separately, how would I go about adding a string of text inside that same

Answer Source

Use .empty() to remove the contents in the Div tag.


For your second question; you can add the any text or content using $('.content').html(newcontent) or

$('.content').text(newcontentText); //specifically for text content.