i guess this is a pretty simple question.
I want to give my li-tags a width that matches the image thats is inside it. So far i am getting my image-attributes right for each one.
$("#slider1 li img").each(function(){
var imageWidth = $(this).width();
var imageHeight = $(this).height();
$(this).attr('width', imageWidth);
$(this).attr('height', imageHeight);
});
But i can't seem to figure out how i transfer the imageWidth to my li-tag. I tried with:
$("#slider1 li").css("width", imageWidth);
But that just renders the same width for all the li's.
Thanks for helping out :)
EDIT: My markup:
<ul id="slider1">
<li><img src="tester.jpg"/></li>
<li><img src="tester2.jpg"/></li>
<li><img src="tester3.jpg"/></li>
<li><img src="tester4.jpg"/></li>
<li><img src="tester.jpg"/></li>
<li><img src="tester2.jpg"/></li>
</ul>