tags:

views:

52

answers:

2

I am doing this with jquery

$().ready( function() {
  $(document).empty();
  $(document).append("<div>hallo</div>");
});

I would have expect it to empty the body and afterwards add an div with hallo into the body. But it doesen't. In firebug it does not show any errors. Why does it not work and how do I make it work?

+1  A: 

Try this.

$(document).ready( function() {
   $("body").empty();
   $("body").append("<div>hallo</div>");
});
blesh
A: 

The quickest way to append something while also emptying the body is as follows:

$(function() {
   $('body').html('<div>hello</div>');
});
cballou