how to get dynamically created elements width and apply style to that?

Posted by 3gwebtrain on Stack Overflow See other posts from Stack Overflow or by 3gwebtrain
Published on 2010-05-30T17:04:59Z Indexed on 2010/05/30 17:12 UTC
Read the original article Hit count: 224

Filed under:
|

Hi, I am creating an li element dynamically like this:

$(data).find('slide').each(function(numSlide){
  var slideLink = $(this).attr('link');
  var slideimage = $(this).children('slideimage').text();
  var slidedesc = $(this).children('slidedesc').text();

  $('.slider ul').append('<li><a href="'+slideLink+'"><img src="'+root+"images/top-slider-image/"+slideimage+'" alt="welcome to Burger Davis Blog" /></a><div class="note">'+slidedesc+'</div></li>');
})

But I'd like to calculate the width of the li, and I need to apply some style to it -- how can I do that? If I add styles via the css method, it does not work for dynamically created elements...

Please help me to get dynamic elements' width and how to apply styles into that?

I know we can use the live function, but I can't get even by that..

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery