次のようなコードがあります。
<div id="container">
// 3 lines other code here
<a hef="#" id="agreelink"><input id="agree" name="agree" value="Agree" style="position:relataive;border-style:none" /></a>
<input id="disagree" name="disagree" value="Disagree" style="position:relataive;border-style:none" />
<input id="abstain" name="abstain" value="Abstain" style="position:relataive;border-style:none" />
// 2 more lines here
</div>
.live()
次に、要素が動的であり、火を複製し続けるために使用していた関数があり、に移動する必要があり.on()
ます。したがって、これらのボタンのいずれかを起動しようとした関数コードは次のとおりです。
<$('#container').on('click', 'input', function() {
alert($(this).attr('name'));
});
と
<$('#container').on('click', '#agree', function() {
alert($(this).attr('name'));
});
と
<$('#container').on('click', 'a', function() {
alert($(this).attr('id'));
});
しかし、私はそれを発火させることができません。オンラインで検索して試してみましたが、何か正しいことをしていないと確信しています。誰かが私が間違っている場所を提案できますか?
ありがとう