jquery - How to combine image map area class with alt attribute to make new class -


I have a picture map with each of 21 states in the US as a separate area. Example:

  & lt; Area class = "area" size = "poly" courses = "66,8,138,27,126,80,103,73" alt = "wa" & gt; & Lt; Area = square = "area 2" size = "poly" cords = "60,15,108,87,26,120,100,53" alt = "ca"> gt;  

Now I have set it up so that each state area has its own square and when clicked, opens a div (class or .ca) instance with information for that is. state.

  $ ('.zone'). Click (function () {$ ('. Wa'). Show ("scale", 350);}); $ ('Area2'). Click (function () {$ ('.ca'). Show ("scale", 350);});  

But there are several codes needed to be repeated. What would I do to combine alt attribute of the image map area in the classroom ("bind"?) So that I do not have to repeat jQuery code for each state area on the image map.

Pseudocode: When clicked, area square + "alt" -> opens the div that matches the new category.

In other words

area (class) + WA (alt) -> .regionWA which opens the div with the class .regionWA.

you can do something like

  $ ('. '). Click (function () {var state = $ (this) .attr ('alt'); $ ('region' + state). Show ('scale', 350);});  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -