[JQuery] highlight event detail with jquery


My html page has multiple events inside a div identified by a prefix and the event's id.

Look at this example:




< id="event_1">...< /div >
< id="event_2">...< /div >...

I want to highlight the selected div when the user click on the link inside it and, in the meantime, deselect all the others divs.
My css:
.time_line_event_highlighted {
background-color:yellow;
}

Here is the jquery snippet:

$("#" + divId).click(function(){ // when a user click on a link inside a div...
$('div[id^=event]').removeClass("time_line_event_highlighted");
$("#event" + id).addClass("time_line_event_highlighted")
...
});

Nessun commento: