Simple answer:

DOM nodes are created by just writing the html in side of the jQuery

$('#divName').append('<table><tr><td></td></tr></table>');

is equivalent to

divResult = document.getElementById("divName");
table = document.createElement("table");
tr = document.createElement("tr");
td = document.createElement("td");
tr.appendChild(tr);
table.appendChild(tr);
divResult.appendChild(table);

but is also cross browser compatible, optimized for speed, and handles
event registrations.

On Mar 3, 9:41 pm, SeeVik <vikramvmalhotra1...@gmail.com> wrote:
> Thanks for the reply Jack. the JST Template looks cool. I will surely
> look into it.
>
> Just for the record, if anybody can throw some light on the original
> question, it would be really helpful.
> I don't really want to be left clueless about this thing in jQuery.
>
> Thanks and Regards
> Vikram
>
> On Mar 4, 12:04 pm, Jack Killpatrick <j...@ihwy.com> wrote:
>
> > This isn't jquery-specific, but I've been using this for a couple years
> > now to generate html from json data:
>
> >http://code.google.com/p/trimpath/wiki/JavaScriptTemplates
>
> > works great.
>
> > - Jack
>
> > SeeVik wrote:
> > > Hello all,
>
> > > I am using Symfony with jQuery plugin. The thing is I am getting some
> > > data from database in JSON format and I want to use jQuery to display
> > > a table using that data on the fly. I was wondering is jQuery the best
> > > way to do this? Or will it be an overkill? Should I use simple DOM
> > > methods for this task like...
>
> > > divResult = document.getElementById("divName");
> > > table = document.createElement("table");
> > > tr = document.createElement("tr");
> > > td = document.createElement("td");
> > > tr.appendChild(tr);
> > > table.appendChild(tr);
> > > divResult.appendChild(table);
>
> > > If I should use jQuery, can somebody give me a hint which methods to
> > > use for the above jQuery code?
>
> > > Thanks and Regards
> > > Vikram

Reply via email to