jQuery.fn.gallery = function(){
return this.each(function(){
var e = $(this);
var h = e.height();
e.height(128);
e.click(function(){
//show big preview
e.clone().height(h).prependTo("body");
})
})
}这段代码的中h取得的e元素的高度在chrome浏览器中始终为0,但是在firefox里面正常显示
怎么解决这个问题啊?求高手指教,我用的jquery-1.7.2.js
e表示的是一个img元素,高度600px
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
</style>
</head>
<body>
<img src="http://avatar.profile.csdn.net/1/7/A/2_prettywhitewolf_xiao.jpg">
<script>
jQuery.fn.gallery = function(){
return this.each(function(){
var e = $(this);
var h = e.height();
e.height(128);
e.click(function(){
//show big preview
e.clone().height(h).prependTo("body");
})
})
} window.onload = function(){
$('img').gallery()
}
</script>
</body>
</html>
参考下
http://bbs.blueidea.com/thread-2980077-1-1.htmlhttp://stackoverflow.com/questions/2501273/cant-get-true-height-width-of-object-in-chrome