<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>先添加事件, 后添加DOM</title>
<script type="text/javascript" src="../global/js/jquery-1.8.1.js"></script>
<script type="text/javascript">
$(function(){
var html = '<li><a href="javascript:;" name="user">陈袁</a></li>';
var temp = $('<ul></ul>').append(html);
temp.find('a[name="user"]').bind('click', say);
$(".container").append(temp);
console.log('---------------- OVER -------------------');
});
function say() {
console.log('======================');
}
</script>
</head>
<body>
Hello World!!!!
<div class="container">
<a href="javascript:;">链接</a>
</div>
</body>
</html>