[jQuery] XHTML or HTML when creating elements?
According to the jQuery documentation we're
supposed to write like this:
$("<span/>")
and not like this:
$("<span>")
http://docs.jquery.com/Core/jQuery#htmlownerDocument
That means using XHTML style code for the
elements created.
Are we supposed to do that even when we are using
HTML style code (e.g. HTML 4.01)?
E.g.:
$('#whatever').html('<img alt="" src="..." />');
That would seem a bit bizarre if the actual HTML
page has lots of '<img alt="" src="">' without the
ending slash.
It does seem that "img", "br" etc. work without the
ending slash as well.
--
Bertilo Wennergren <http://bertilow.com>