CSS设置图片大小JS怎么获取?

2025-02-23 23:05:22
推荐回答(3个)
回答1:

img{height:200px;width:200px};



function ShowIt(img) {
var realImg = document.createElement("img");
realImg.src = img.src;
alert(realImg.width + ", " + realImg.height);
}

回答2:

假设图片是,图片的宽度为width,高度为height

var width = $("img").width();
var height = $("img").height();

回答3:

function PreviewImg(imgpath){
var image=new Image();
image.src=imgpath;
alert(image.width);
alert(image.height)
}