Changing image src and css properties of new image
Hi.
I have written a quick function to change the src attribute of an
image. I also need to set some CSS properties on that image's parent
to get it to stay centered in the containing div. Here is the code
I've written.
-
$("#list .item a").click(function() {
var imgPath = $(this).attr("href");
$("#left p img").hide().attr({ src: imgPath }).fadeIn(600);
var workImgHigh = $("#work #left p img").height();
$("#work #left p").css({"height":workImgHigh+"px","margin-top":"-"+workImgHigh/2+"px","top":"50%"});
return false;
});
The problem is that variable workImgHigh is getting set on the height
of the original image in that spot, _before_ the src changes.
How can I modify this to have the variable grab the height of the
incoming image?
Thanks much,
Marcus