Search code examples
jqueryhtmlcssappendto

Using jQuery to load content and appendTo an element


I want to use ajax to load some HTML, and then place it as the last child of a <div>.

$('div').load('extra-stuff.php'); will replace all content of the div. appendTo() sounds promising, but now what is the most efficient jQuery AJAX function to use, and how can it work with appendTo?


Solution

  • Try the jQuery.get() method

    $.get('extra-stuff.php', function(data){
        $('div').append(data);
    });