[jQuery] Re: XHTML or HTML when creating elements?

2009-09-25 Thread Karl Swedberg
On Sep 25, 2009, at 11:56 AM, Bertilo Wennergren wrote: Karl Swedberg wrote: Internally, jQuery determines whether to use document.createElement by checking the string against a regular expression: rsingleTag = /^<(\w+)\s*\/?>$/ Unless I'm missing something, allowing for both syntaxes wo

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-25 Thread Bertilo Wennergren
Karl Swedberg wrote: Internally, jQuery determines whether to use document.createElement by checking the string against a regular expression: rsingleTag = /^<(\w+)\s*\/?>$/ Unless I'm missing something, allowing for both syntaxes would be trivial. Just change the regex to something like

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-25 Thread Bertilo Wennergren
Vincent Robert wrote: > On Sep 24, 6:33 pm, Bertilo Wennergren wrote: >> 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" (

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-25 Thread Karl Swedberg
On Sep 25, 2009, at 10:21 AM, Vincent Robert wrote: Actually, jQuery does some parsing by itself first. The $('') syntax is actually a shortcut to document.createElement("span"), and yes, the "/" is required here. So $ ('') will be faster than $('') which will have to go through innerHtml.

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-25 Thread Vincent Robert
Actually, jQuery does some parsing by itself first. The $('') syntax is actually a shortcut to document.createElement("span"), and yes, the "/" is required here. So $ ('') will be faster than $('') which will have to go through innerHtml. Regards, On Sep 24, 6:33 pm, Bertilo Wennergren wrote:

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Richard D. Worth
On Thu, Sep 24, 2009 at 1:36 PM, Bertilo Wennergren wrote: > > The question about "" arose when I was demonstrating > how the same inline JS example is supposed to look like in HTML > and in XHTML. When I was changing one version from it's XHTML > incarnation into an HTML incarnation, removing all

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Bertilo Wennergren
Richard D. Worth wrote: On Thu, Sep 24, 2009 at 12:53 PM, Bertilo Wennergren wrote: Richard D. Worth wrote: Best practice, valid HTML, and compatible with XHTML would be $('#whatever').html(''); $('#whatever').html(''); $('#whatever').html(''); Well, not quite "valid" HTML... quite va

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Richard D. Worth
On Thu, Sep 24, 2009 at 12:53 PM, Bertilo Wennergren wrote: > > Richard D. Worth wrote: > > Best practice, valid HTML, and compatible with XHTML would be >> $('#whatever').html(''); >> $('#whatever').html(''); >> $('#whatever').html(''); >> > > Well, not quite "valid" HTML... > quite valid. See

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Bertilo Wennergren
Richard D. Worth wrote: Best practice, valid HTML, and compatible with XHTML would be $('#whatever').html(''); $('#whatever').html(''); $('#whatever').html(''); Well, not quite "valid" HTML... If you use "" in an HTML 4.01 page, the validator at "w3.org" gives a warning with the following ex

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Richard D. Worth
Best practice, valid HTML, and compatible with XHTML would be $('#whatever').html(''); $('#whatever').html(''); $('#whatever').html(''); - Richard On Thu, Sep 24, 2009 at 12:33 PM, Bertilo Wennergren wrote: > > Richard D. Worth wrote: > > I won't speak to the jQuery documentation, nor jQuery's

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Bertilo Wennergren
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 "be

[jQuery] Re: XHTML or HTML when creating elements?

2009-09-24 Thread Richard D. Worth
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: *Non-void elements (sometimes called non-empty elements, meaning they can contain text and child nodes)* For an empty