点击按钮我添加动态元素例如:锚点标签有一些ID, 点击动态元素警报应该打开哪些没有发生。jquery事件不适用于动态元素
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#submit").on("click",function(){
$("#op").html("<a href='javascript:void(0)' id='demo'>Click</a>");
});
$("#demo").on("click",function(){
alert('In Demo....');
});
});
</script>
</head>
<body>
<button id="submit">Submit</button>
<pre id='op' ></pre>
</body>
</html>
[动态创建元素上的事件绑定?]可能重复?(http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – Azim