2

jQuery で選択したオブジェクトを関数に渡そうとしていますが、関数はそれに対して実行.html()します。

HTML:

<div id="box">this is a box</div>

J:

var fillBox = function(box, text) {
  box.html(text);
}

(function() {
  var box = $("#box");
  fillBox(box, "new text");
});

"this is a box"関数が呼び出されても、ボックスはそのままで更新されません。$(box).html(text)関数内で試してみましたが、修正されません。これは実行可能ですか?

http://jsbin.com/iqixoj/5/edit

4

1 に答える 1

8

あなたは忘れました$

$(function() {
  var box = $("#box");
  fillBox(box, "new text");
});
于 2013-01-31T19:52:06.357 に答える