Home › Forums › JavaScript › [Solved] Set div height to the img inside it’s height › Re: [Solved] Set div height to the img inside it’s height
July 27, 2010 at 1:05 pm
#80484
Participant
Got it although I feel bad that I just wasted some forum space but maybe this’ll help someone later. I changed css to just .width() and .height() and tossed in the variables. Easy peasy.
Code:
$(function() {
var $example = $(‘div#example’);
var $example = $(‘div#example’);
$(‘a.link’).click(function() {
$(this).siblings().clone().prependTo(‘#example’);
var imgWidth = $(‘#example img’).css(‘width’);
imgHeight = $(‘#example img’).css(‘height’);
$example.width(imgWidth);
$example.height(imgHeight);
});
});