I have the following code:
$("#rade_img_map_1335199662212").hover(function () {
$("li#rs1").toggleClass("active"); //Toggle the active class to the area is hovered
$("li#rs1").fadeIn("slow");
});
I need to add the class active then fadeIn. I have css which has li'rs1 set to visibility:hidden and when the class is applied i simply style that.
How can i utilise fadeIn?
Also am i structuring this right? – I have 13 different li#rs1, li#rs2 … all the way to li#rs13 with different image map ids. This is why i think i need 13 blocks of code.
EDIT: I have area ids so need need to reduce the code down:
$(document).ready(function () {
$("map#rade_img_map_1335255669666 area#1").hover(function () {
$("li#rs1").toggleClass("active"); //Toggle the active class to the area is hovered
});
});
Your selector can pick up all the relevant items like this:
OR, if you have an id on the list (e.g.:
<ul id='myUlId'>), it’s even easier:Then:
UPDATE …or even easier yet, cover it all in one fell swoop!:
UPDATE 2
To apply to an li with an id corresponding to the hovered area:
UPDATE 3
…if the area doesn’t have an id, then you’ll need a way to scrape the appropriate number out of some other attribute that contains it, like an href. Say the hrefs all have the index numbers somewhere in them in a regular patter, and, say, no other numbers, then you could grab them using
if you have control over the map’s markup structure, the coolest (HTML5, but backward-compatible) thing would be to place the indexes in a data- attribute like this:
Then grab a slector for the li in one line inside the hover function for the area like this: