Ajax の完了後に呼び出す次の関数があります。
function name(results)
{
var str='';
str+='<div id="newDiv"></div>';
str+='<input type="text" value="'+results.name+'" id="newTextbox"></input>';
$('#otherDiv').html(str);
}
それから私は使用newDiv
しnewTextbox
ました
$('#newDiv').html('Example Text');
それは私にとってはうまくいきます。しかし、私が使用するとき
$('#newTextbox').click(function(){
alert('CLICK WITHOUT LIVE');
});
動作していません。次に、次のように変更しました。
$('#newTextbox').live("click",function(){
alert('CLICK WITH LIVE');
});
それは私のために働いています。
私の質問は、両方 ( newDiv
、newTextbox
) が動的に作成されることです。
$('#newDiv').html('Example Text');
live を使わずに動作しているのに、クリックイベントが動作しないのはなぜnewTextbox
ですか?