$("img").click(function () {
$("#galleryImg").html("<img src= images/full_size/" + selectedImg + " alt= " + selectedImg + " />");
var imgHeight = $("#galleryImg img").height();
}
现在使用的Im方法没有奏效,我可以不使用美元,因为我想要高的图像不同于我所点的图像。 为了使其更加复杂,我所希望的顶端是,在职能范围内创建其html的 im。
相关领域的整部法典如下:
$("img").click(function () {
$("div#blackOut").fadeTo(550, 0.8);
$("div#whiteBox").fadeTo(550, 1);
var browserHeight = $(window).height();
var browserWidth = $(window).width();
var imgName = $(this).attr("src");
var imgArray = $(this).attr( src ).split( / );
var selectedImg = imgArray[imgArray.length-1];
$("#galleryImg").html("<img src= images/full_size/" + selectedImg + " alt= " + selectedImg + " />");
$("#galleryImg img").load(function() {
var thatHeight = $("#galleryImg img").height();
alert(thatHeight);
});
var top = (browserHeight - (imgHeight + 50)) / 2;
var width = imgHeight + 50;
var marginLeft = -(width / 2);
var top = top + "px";
var width = width + "px";
var marginLeft = marginLeft + "px";
$("#whiteBox").css("top", top);
$("#whiteBox").css("width", "width");
$("#whiteBox").css("margin-left", "marginLeft");
});