1

編集:

私のファイルにあるコードは次のとおりです。

関連する 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();

次に、なぜ書き込み高さが null なのかわかりません。ご覧いただきありがとうございます。

元の投稿:

要素の高さの値を変数に格納しようとしているので、それを使用して他の要素の高さを設定できます。私の問題は、高さを保存することです。私はこれを試すことができると思いました:

var writingheight = $("#writing_"+p).height;

(div# writing_x要素がいくつかあります。)

writingheight高さの値の代わりに長い混乱が保存されるのはなぜですか?

4

2 に答える 2

1

で実行する必要があり()ます。または、jquery 関数を変数に割り当てているだけです。

var writingheight = $("#writing_"+p).height();
于 2012-08-16T02:11:57.757 に答える
0

() を忘れないでください。height() と書く必要があります。

于 2012-08-16T02:15:23.583 に答える