0

javascriptでテキストボックスを作成し、onclickで関数に引数を渡すことはできますか? コメントアウトされた行の下に問題があります

var inputBox = document.createElement("input");

inputBox.staff = project.staff[j].name;
inputBox.defaultValue = inputBox.staff;
inputBox.onchange = changeHours;

//inputBox.onclick = selectText(this);
4

3 に答える 3

3
inputBox.onclick=function(argument){
  selectText(this);
};
于 2013-03-19T06:12:39.130 に答える
2

試す

inputBox.onclick=function(){selectText(this)};

http://www.w3schools.com/jsref/event_onclick.asp

于 2013-03-19T06:10:29.660 に答える
0

onclick必要な機能で設定するだけです。

var inputBox = document.createElement("input");

inputBox.staff = project.staff[j].name;
inputBox.defaultValue = inputBox.staff;
inputBox.onchange = changeHours;
inputBox.onclick = function() {
    selectText(this);
};
于 2013-03-19T06:14:01.123 に答える