我有一代码,我想用jquery取2012-313.gif图片的高度,怎么取??
<div id='new1' style='margin:auto; display:none; width:960px; top:0px; height:0px;overflow:hidden;'><img src='/images/2012-313.gif' width='960' height='381' border='0' usemap='#Map' id='img1'/><map name='Map' id='Map' > <area shape='rect' coords='900,5,954,30' onclick='javascript:$('#newyear').animate({height:0},{duration:'slow'})' /> <area shape='rect' coords='44,7,888,369' target='_blank' href='/years.html' /></map></div> <div id='yearsNotice' style='margin:auto; display:none; width:960px;'><a target='_blank' href='/year1.html'><img src='/images/2012-313-1.gif' width='960' height='32' border='0' /></a></div>
<div id='new1' style='margin:auto; display:none; width:960px; top:0px; height:0px;overflow:hidden;'><img src='/images/2012-313.gif' width='960' height='381' border='0' usemap='#Map' id='img1'/><map name='Map' id='Map' > <area shape='rect' coords='900,5,954,30' onclick='javascript:$('#newyear').animate({height:0},{duration:'slow'})' /> <area shape='rect' coords='44,7,888,369' target='_blank' href='/years.html' /></map></div> <div id='yearsNotice' style='margin:auto; display:none; width:960px;'><a target='_blank' href='/year1.html'><img src='/images/2012-313-1.gif' width='960' height='32' border='0' /></a></div>
建议这种问题查一下帮助 文档
为零,取不到的
可以得到啊。。为381
var getHeight = function(p, img){
var pStyle = p.style, h;
pStyle.visibility = 'hidden';
pStyle.display = 'block';
h = img.offsetHeight;
pStyle.visibility = '';
pStyle.display = '';
return h;
}
getHeight(document.getElementById('new1'),document.getElementById('img1'))