Best practice, valid HTML, and compatible with XHTML would be $('#whatever').html('<div></div>'); $('#whatever').html('<br />'); $('#whatever').html('<img alt="" src="..." />');
- Richard On Thu, Sep 24, 2009 at 12:33 PM, Bertilo Wennergren <berti...@gmail.com>wrote: > > Richard D. Worth wrote: > > I won't speak to the jQuery documentation, nor jQuery's internal >> implementation for $(html), only your questions about HTML and XHTML, >> based >> on my own knowledge and best practices: [...] >> > > Thanks! > > So if I understand your points, the following examples can be called "best > practices" when using jQuery along with HTML 4.01: > > $('#whatever').html('<div></div>'); > $('#whatever').html('<br>'); > $('#whatever').html('<img alt="" src="...">'); > > Actually I code everthing in XHTML, but I still wondered > how this is supposed to be done in jQuery in old style HTML. > > I think I read somewhere that jQuery just passes the > code along to the "innerHTML" function of the browser. > That would mean that the actual rules are those of the > browsers' various implementations of "innerHTML" (whatever > those may be...). > > > -- > Bertilo Wennergren <http://bertilow.com> >