<!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>
I don't see any difference between these two when i run the code as it clones the element to my div tag. What's so special with the bind method?
http://api.jquery.com/category/events/
I was looking at the docs, correct me if i am wrong... if the click and bind does the same thing, why they have two different ways to achieve the same?.