时间:2021-07-01 10:21:17 帮助过:7人阅读
结果为:200
<div id="cc"></div>
<script>
$(document).ready(function() {
$("#cc").append("<div id='aa' style='width:200px;height:200px;' /></div>");
alert($("#aa").width());
});
</script>
结果为:
<div id="cc"></div>
<script>
$(document).ready(function() {
$("#cc").append("<img id='aa' src='//www.gxlcms.com/images/logo.gif' />");
alert($("#aa").width());
});
</script>
(注:image1.jpg的实际宽为693)
<div id="cc"></div>
<script>
$(document).ready(function() {
$("#cc").append("<img id='aa' src='//www.gxlcms.com/images/logo.gif' />");
window.setTimeout(function(){alert($("#aa").width()); },100);
});
</script>
有解决过此问题或有关于此问题更详细的认识的大鸟还望不吝赐教..
代码如下:
$(document).ready(function() {
$("#cc").append("<img id='aa' />");
$("#aa").load(function(){
alert($("#aa").width()
}).attr("src", "//www.gxlcms.com/images/logo.gif");
});