« Return to Thread: Creating an empty jQuery object

Re: Creating an empty jQuery object

by Danny Wachsstock :: Rate this Message:

Reply to Author | View in Thread

This may be hijacking the thread, so I'll keep it brief. i agree that innerHTML is useful, and it is a de-facto standard (like AJAX). I also agree that whatwg's work is much closer to reality than w3g's, and like I said, I'm not a fanatic standardista. My point is that it's harder to debug complicated strings than language constructs, since the language will tell you there's a syntax error right away. As in
$("<div class='first'><div><div>"+"</div></div>");
It would take me forever to find that I missed a closing div, and keeping track of all the quotes is well-nigh impossible. To use my function,
$.dom('div', {Class: 'first'}, ['div',{},['div',{},['span', {style: {color: getColor()}}]]])
and if I screw up a parenthesis or brace, Firebug will tell me right away.

For simple things ($("Hello") I'll use innerHTML, and certainly if someone else is taking responsibility for generating the string (as in AJAX), there's nothing easier than innerHTML.

Danny

Sam Collett wrote:
I may not be a guru (but have been using it for a long time), but
while jQuery does use innerHTML, it does in a way to work around
limitations in the browsers. Without it, I don't think you would be
able to create select options or table cells/rows via the $("<html>")
method.

All of the supported browsers recognise innerHTML and I can't see it
going away any time soon, or any new browser shipping without support
for it as so many sites rely on it to work. Much like how XHTML strict
(served with correct content type) will likely never see widespread
adoption. I think HTML 5 (http://blog.whatwg.org/faq/) is more likely
to take off IF Internet Explorer 8 adopts it (as it simply expands on
what people use now, and is not a complete break from HTML like XHTML
2 is), but as Microsoft are pushing XAML that may not happen.

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

 « Return to Thread: Creating an empty jQuery object