Detecting button clicks
Clicking on website elements is a primary user interaction; therefore, detecting these clicks is a very fundamental aspect in creating interactive web applications. There are various ways in which jQuery developers can listen for certain button presses within their web page.
Getting ready
Using your favorite text editor or IDE, create a blank HTML page named recipe-1.html
in an easily accessible location.
How to do it…
Create two buttons with click event handlers by performing the following steps:
- Add the following HTML code to
recipe-1.html
. Be sure to change the location of the jQuery library in the JavaScript file, pointing it to where the latest version of jQuery is downloaded on your computer.<!DOCTYPE html> <html> <head> <title>Chapter 2 :: jQuery Events</title> <script src="jquery.min.js"></script> <script> </script> </head> <body> <button class="button1...