首页javascriptclassjQuery Style - 如何添加和删除类

jQuery Style - 如何添加和删除类

我们想知道如何添加和删除类。


<!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.w3cschool.cn/style/download.png" />
  </div>
</body>
</html>