tags:

views:

32

answers:

3

I have an empty div at the beginning:

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

I know how to add for the first time html into my empty div using jQuery:

$('#mydiv').html('my html!');

But my problem is that I don't know how to push more html at the end of my non-empty div:

 <div id="mydiv">my html!**how to add more html here**</div>
+6  A: 
$('#mydiv').html('my html!');
$('#mydiv').append('more html!');
Jakub Konecki
thank you, was looking for append() ! :)
whothedonk
+2  A: 
$('#mydiv').append($('**how to add more html here**'));

For adding it at the beginning use prepend.

Neil
+1, Its nice that you also mention mentioned.
Starx
@Neil - You can pass a string to append without calling jQuery on it.
Jakub Konecki
Wasn't sure, so I thought I'd add it anyway. Meh.
Neil
A: 

This is actually pretty straightforward:

$("#mydiv").html($("#mydiv").html() + " I want to add html here");
Morph
Ah didn't realise there is append as well. Oh well :).
Morph