Reputation: 35
EDIT:
Here is the code exactly as it is in my file:
Relevant 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>
Clicking this will call the function andherewego(p). Here is that function:
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);
}
This function calls hackemoff(p), which I have put below:
function hackemoff(p){
var writingheight = $("writing_"+p).height();
alert(writingheight);
$("#paper").height(writingheight-300+50);
$("#marginline").height(writingheight+50);
$("#back_"+p).height(writingheight+50);
}
That is the code. If my syntax is indeed flawless, as you say, for the line
var writingheight = $("writing_"+p).height();
then I do not understand why writingheight is null. I am grateful for you to be looking at this.
ORIGINAL POST:
I am trying to store the value of an element's height in a variable, so I can use it to set the height of other elements. My issue is with storing the height. I thought I could try this:
var writingheight = $("#writing_"+p).height;
(There are several div#writing_x elements.)
Why does this store a long mess in writingheight
instead of the height value?
Upvotes: 1
Views: 3421
Reputation: 160883
You need to execute it by ()
, or you are just assigning the jquery function to the variable.
var writingheight = $("#writing_"+p).height();
Upvotes: 1