var $div = $('<div class="error">').appendTo($('#header'));
When creating new elements and adding them to the DOM, do you need the ending tag? why or why not? Do I only need the ending tag if i’m placing content into the tag i’m creating? like so:
var $div = $('<div class="error"> Error-Homie! </div>').appendTo($('#header'));
or could I create an element with content in it, but leave out the ending tag? Good? Bad?
var $div = $('<div class="error">').appendTo($('#header'));
Although it may work if you don’t use a closing tag (or at least self close the tag), you should add a closing tag (self-close) (as mentioned, for cross-platform compatibility):
This is how jQuery creates the elements:
Btw. you can also pass the data as second parameter: