I've got a number of pictures with captions that will be floated  
right in the main body text. The HTML looks like this:

<div class="image">
     <img src="myimage.jpg" width="250" height="350" alt="Image  
description">
     <p>A caption for the image</p>
</div>

Because the images will vary in width, I don't want to hard-code the  
width into the stylesheet. But I don't want the caption ever to be  
wider than the image.

So I tried the following:


$('div.image p').width( $(this).prev().width() );


In theory, this should set the width of the caption paragraph to the  
same as the width of the image preceding it; but it doesn't work.

What have I done wrong?


Seb


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to