87,990
社区成员
发帖
与我相关
我的任务
分享<img src="1.jpg" id="imgId" />var img = new Image();
img.src = $("#imgId").attr("src");
if (img.complete) {
alert("宽度:" + img.widht + ",高度:" + img.height);
} else {
img.onload = function() {
alert("宽度:" + this.width + ",高度:" + this.height);
}
}
<script>
var pic=document.createElement("img");
pic.src="a.jpg";
document.body.appendChild(pic);
alert(pic.offsetHeight);
</script>