"A personality change?" I hear you ask. Yes, that's right; our dog seems to like miaowing…. (I can't think of a reason why; I don't know of any that would!)
In our example, we're going to use a simple click handler to prove that (in some cases) our dog can meow; we will then work through what is required in order to persuade it to do what it should do.
Let's start by cracking open a text editor of our choice and then adding the following markup as a basis for our patch:
<!DOCTYPE html> <head> <title>Demo: Basic Duck Punching</title> <meta charset="utf-8"> <script src="js/jquery.min.js"></script> <script src="js/duck.js"></script> </head> <body> <div>Hello World</div> <button>Make it a dog!</button> </body> </html>
Save it as the
duck.html
file. In a separate file, we need to animate our button, so let's first add in a simple event handler for this purpose...