<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>css demo</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function(){
$('button').click(function(){
//$(this).clone().appendTo('div');
$(this).clone().prependTo('div');
})
$('button').bind('click', function(){
$(this).clone().appendTo('div');
})
});
</script>
</head>
<body>
<h1> My WebSite</h1>
<div>
<button data-file="day">Day</button>
<button data-file="night">Night</button>
</div>
</body>
</html>
当我将代码克隆到我的div标记中时,我没有看到这两者之间有什么区别。绑定方法有什么特别之处?jQuery中的绑定和点击之间的确切区别?
http://api.jquery.com/category/events/
我一直在寻找的文档,纠正我,如果我错了......如果点击绑定做同样的事情,为什么他们有两种不同的方式来达到同样的?
**确切的**区别在于一个有五个字母,另一个有四个字母,而且这两个方法有两个完全不同的名称。他们在内部完全一样。 – adeneo
阅读这个 http://stackoverflow.com/questions/2954932/difference-between-jquery-click-bind-live-delegate-trigger-and-on –