We would like to know how to add and remove class.
<!-- ww w .j a v a2s .c o m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<style type='text/css'>
.Hover {
border: 1px solid #000;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$("#imgBorder img").hover(
function() { $(this).addClass("Hover"); },
function() { $(this).removeClass("Hover"); }
);
});//]]>
</script>
</head>
<body>
<div id="imgBorder">
<img src="http://www.java2s.com/style/download.png" />
</div>
</body>
</html>
The code above is rendered as follows: