+ JavaScript の質問用スレッド vol.98 +at HP
+ JavaScript の質問用スレッド vol.98 + - 暇つぶし2ch782:Name_Not_Found
12/03/29 19:52:22.45 K1Gn5nTR
>>780
んで、俺だったらこんなふうにします

var path = ['hoge','fuga']; // 値

function run(p){ alert(p); }

for(var i=0,l=path.length ; i<l ; i++)(function(p){ // ループ

  var path = p;
  var button = document.createElement("input");
  button.type = 'button';
  document.body.appendChild(button); // 設置
  button.addEventListener('click',function(){
    run(path); // 動作。ここからならループのスコープは参照できる
  },false);

})(path[i]);


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch