编辑:
以下是与我的文件完全相同的代码:
相关HTML:
<a href="javascript:void(0);" onmouseover="return overlib('Farewell - N.C. Hunter Hayden', HEIGHT, -1, WIDTH, -1, ABOVE);" onmouseout="return nd();" onclick="andherewego(1); setTimeout(function(){document.getElementById('farewell').play();},965);"><div id="note_1"></div></a>
单击此按钮将调用函数andherewego(p)。这是函数:
function andherewego(p){ // p is the # of the note pressed
initiatestafffade(); // set times for notes and notation to fade,
// and fades them
setTimeout(function(){
changingoftheguard(p); // show writing_p, paper, marginline,
// back_p
hackemoff(p); // re-define height for paper, marginline,
// back
hidingfromjudgement(p); // determines how many covers to show and
// shows
// them
nowheretohide(p); // set times for covers to fade, and fades
//them
}, 950);
}
这个函数调用hackemoff(p),我把它放在下面:
function hackemoff(p){
var writingheight = $("writing_"+p).height();
alert(writingheight);
$("#paper").height(writingheight-300+50);
$("#marginline").height(writingheight+50);
$("#back_"+p).height(writingheight+50);
}
这就是代码。如果我的语法确实完美无缺,正如你所说,对于行
var writingheight = $("writing_"+p).height();
然后我不明白为什么writeheight为null。我很感激你看到这个。
原始邮件:
我试图将元素高度的值存储在变量中,因此我可以使用它来设置其他元素的高度。我的问题是存储高度。我以为我可以试试这个:
var writingheight = $("#writing_"+p).height;
(有几个div #writing_ x 元素。)
为什么这会在writingheight
而不是高度值中存储长时间的混乱?
答案 0 :(得分:1)
您需要通过()
执行它,或者您只是将jquery函数分配给变量。
var writingheight = $("#writing_"+p).height();
答案 1 :(得分:0)
别忘了(),你应该写下height()