Sure, you can do this with html.

Inside the success callback function, do this:

$(html)
  .find("td")
    .css('padding-left','80px')
  .end()
   .appendTo('#myTable');


I agree with Charlie that it's a better idea to set the style with css and then just add a class to the td elements. Whether you do that server-side or in the success callback is up to you.

Also, you ought to append table rows to a <tbody>, not to a <table>.


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Oct 1, 2009, at 11:52 AM, Charlie wrote:

if it was json or xml could parse it then append, I've never tried parsing html from ajax

another method is append to an empty hidden table, add classes/css or whatever to the td's in that table then append them to your visible table

Julien wrote:

On 1 oct, 16:26, Charlie <[email protected]> wrote:

you are trying to apply css to something that isn;t in the DOM. $.css() uses inline style attribute so if there is no html inline the attribute can't be applied
can you add class name to html server side and use css to pad?
if not you could add class to exisitng td's before insertion of new html, insert your AJAX, then do something like
$("td").not('existTDClass').css(.............


Thanks Charlie.
The answer you're giving me is what i was actually going to do.
But i'm surprised that you can't do something like that straight with
jquery.

The functions find() and filter() seems to work on html returned by
jquery ajax.
It seems very close to what i need.

So there is no other way at all?




Reply via email to