Join Chris Converse for an in-depth discussion in this video Adding click events to the anchor tags, part of Creating an Interactive Map with jQuery.
Now to add click events to those dots we're going to come back to our map.js file, …outside of the map change function but still inside of the document ready.…Let's hit a few Returns. Let's start by typing dollar sign, beginning and…ending parentheses, two tick marks for string literal, a.dot. Outside of…the parentheses we're going to type .click();…Inside of the parentheses for click, we're going to type function, beginning and…ending parentheses, beginning and ending bracket, split that on the…brackets, and the first thing I want to do is test the click function and I also…want to return the value of the dot that was clicked on.…
So let's type an alert, parentheses, inside of the parentheses. Let's type dollar sign,…beginning and ending parentheses. Inside of the parentheses we're going to type…(this).attr for attribute, parentheses. Inside of the attribute, two tick marks for…string literal. We're going to type city.…Now what that this function does here is it returns the actual dot that was clicked on.…
Take a look at the finished web site here.
- Preparing web graphics
- Creating the main container
- Manipulating links with CSS
- Adding a drop-down menu
- Downloading jQuery and adding interactivity to a project
- Creating city details
- Overriding click events of anchor tags with jQuery