<script>
$('#click').click(function (e) {
e.preventDefault();
var id = $('#id').val();
$.ajax({
type: "POST",
url: "ajaxcode.aspx/fun",
data: "{'str' : '" + id + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (resopnse) {
$('.col-md-9').append("<a id='clickID'>More</a>");
}
});
});
$('#clickID').click(function (e) {
e.preventDefault();
alert("CLICKED");
});
</script>
我在AJAX追加<a>
与ID的clickId,并就<a>
我再跑功能,但它不能正常工作。第一个函数成功运行,但第二个函数不起作用。有什么错误吗?Click事件不工作锚
的可能的复制[事件绑定上动态创建的元素?](https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements ) – Dmitry