This should work: $('div.image p').width($('div.image p').prev().width());
Although I am not sure why $(this) would not work; perhaps someone else will know why? On 2/13/07, Seb Duggan <[EMAIL PROTECTED]> wrote:
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 discuss@jquery.com http://jquery.com/discuss/
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/