Nice use of join()! I'm new to JavaScript and jQuery both, and it's
nice to come across little snippets like this I can readily add to my
jQuery repetoire and that slightly expand my understanding of
JavaScript.

By the way, the docs show that it's legal to pass, as an argument to
append(), either a jQuery object (as you're doing), a DOM element, or
a string. So you really don't need to wrap the stringified array in a
jQuery object before you pass it in. Unless there's another reason for
doing so that I'm missing.

Apropos to the above, I wonder why the docs for appendTo() show a
string as being the only legal argument type? I tried a test passing
in a jQuery object instead and it worked just fine. Does that mean you
can use a jQuery object *any* time a string is called for in other
jQuery methods as well? Or just a case of the documentation needing to
be adjusted in this one case?

Howard

On Sep 29, 11:17 am, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > From: James Dempster
>
> > I've never really understood the point to FlyDOM. It seems
> > like a nice idea, but whats wrong with just using jQuery?
>
> > FlyDOM
> > $('#exampleCA').createAppend(
> >     'table', { width: '718px', style: 'border: 2px inset #336699;' }, [
> >         'tr', { className: 'exampleRow' }, [
> >             'td', { align: 'center', style: 'color: white;' },
> >                 'I was created by createAppend()!'
> >         ]
> >     ]
> > );
>
> > jQuery
> > $('#exampleCA').append($(
> >     '<table style="width:718px;border:2px inset #336699">'+
> >         '<tr class="exampleRow">'+
> >             '<td style="text-align:center;color:white;">'+
> >                 'I was created by jQuery append'+
> >             '</td>'+
> >         '</tr>'+
> >     '</table>'
> > ));
>
> > As far as I can tell both of these would do the same thing?
> > They're both as easy as each other, maybe jQuery is even
> > easier as it's plain html. Would the jQuery version be faster
> > also as it could just inject the html into the DOM using
> > something like innerHTML.
>
> Yes indeed, innerHTML is faster than DOM insertion, and you also remove the 
> overhead of the code that interprets the element list.
>
> In fact, I wrote the first jQuery DOM plugin, and I don't use my own plugin 
> any more!
>
> You can improve the speed even more by using [].join instead of string 
> concatenation:
>
>  $('#exampleCA').append($( [
>      '<table style="width:718px;border:2px inset #336699">',
>          '<tr class="exampleRow">',
>              '<td style="text-align:center;color:white;">',
>                  'I was created by jQuery append',
>              '</td>',
>          '</tr>',
>      '</table>'
>  ].join('') ));
>
> In your simple test case it won't make any difference, but if you are 
> stringing together a lot of HTML code, [].join will speed it
> up in most browsers.
>
> -Mike

Reply via email to