Tilak Raj
Tilak Raj

Reputation: 1499

Replace the div elements after ajax call instead of appending to it

I have a div element inside my php script, <div id="abc"></div> however it contains some other div elements as well.What this div element look like is

<div id="abc">
    <div>
        //some content
    </div>
</div>

I am using jquery ajax to .append() some returned html content inside the abc div but what it does is that it simply appends the response html content to the abc div. Obviously the name says so ,what i wanna know it that is there any function like which replaces all the content inside, by the returned content instead of appending to it ?

Upvotes: 0

Views: 518

Answers (2)

bastiherrmann
bastiherrmann

Reputation: 43

If i got you right

$('#abc').html(result);

should do the trick. It will just replace the content of your abc-div.

Upvotes: 1

Ibrahim Khan
Ibrahim Khan

Reputation: 20740

Use html() instead of append().

$('#abc').html(response);

Upvotes: 2

Related Questions