Q:

Using jQuery to assign an active class to an area tag (image map)

Is there a way, through jQuery, to assign an active class to an area tag within an a map?
I have a bunch of areas defined like this:
<map name="mappy"> 
    <area shape="rect" coords="162,105,179,136" href="#" title="Unique Title 1" alt="Unique Title 1" /> 
    <area shape="rect" coords="205,72,222,101" href="#" title="Unique Title 2" alt="Unique Title 2" /> 
</map>

What I need to figure out is if it is possible to add a some jQuery that sniffs out the title or alt tag and applies an active class to the area if there is a match.
Something like... if title="Unique Title 1" then add class="active" to area.  Is this possible?

A:

You can use the attribute-equals selector to find it and .addClass() to do the actual adding, like this:
$("area[title='Unique Title 1']").addClass("active");

