<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("span").click(function(){
alert(1);
})
$("div").append("<span>this is a test</span>");
})
</script>
</head>
<body>
<div></div>
</body>
<html>
<head>
<title></title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("span").click(function(){
alert(1);
})
$("div").append("<span>this is a test</span>");
})
</script>
</head>
<body>
<div></div>
</body>
</html>
加载时间时,新节点还没有添加到DOM之中,因此事件无法完成绑定