Alex Rivera | Logout

How can jQuery load some html and append it to the <body> element?

Asked 2009-09-06T13:10:09.670
23

I tried the following:

$.load("Views/chatBox.html").appendTo('body')

Console Output:

TypeError: $.load is not a function 

EDIT: The answer should only be one line of code; that's enough, I think.

Edit
Report

1 Answer

3

An alternative solution:

jQuery('#AppendToMe').append( jQuery('<div>').load(...) );

This will append whatever you load into the #AppendToMe element.

answered 2013-04-08T19:03:49.520

Your Answer