[jQuery] Outline html elements on hover and click

[jQuery] Outline html elements on hover and click


Hi
Am a jquery novice and are trying to make code that adds a hover event
to all html elements within a certain container. On hover the element
should be outlined by adding/removiing a css class. Thats the first
thing and I can't get that to work with the code below.
The second part is to keep the element outlined when its clicked, and
also when selecting multiple elements by (ctrl+click).
Have searched for a outline plugin, but came up with nothing.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="js/jquery.js"></script>
<script language="JavaScript" type="text/javascript">
$(function(){
$( "#divCodeArea" ).each(function()
{
$(this).hover
(
function()
{
$(this).addClass("outlineElement");
},
function()
{
$(this).removeClass("outlineElement");
}
);
}
);
});
</script>
<style type="text/css">
#divCodeArea
{
border: solid 2px gold;
padding: 10px;
}
.outlineElement
{
border: solid 1px red;
}
</style>
</head>
<body>
<div id="divCodeArea">
<div>
1111111111111111111111111</div>
<div>
2222222222222222222222222</div>


333 <span>4444</span> 55555 <span>666666</span>


<span>7777777</span>
<ul>
<li>AAAA</li>
<li>BBBB</li>
<li>CC<span>XX</span></li>
<li>DDDD</li>
<li>EEEE</li>
<li>FFFF</li>
</ul>
</div>
</body>
</html>
/Cheers