<!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 タグに複製されるため、これら 2 つの違いはわかりません。bind メソッドの何が特別なのですか?
http://api.jquery.com/category/events/
私はドキュメントを見ていました。私が間違っている場合は修正してください...クリックとバインドが同じことを行う場合、同じことを達成するために2つの異なる方法があるのはなぜですか?.