用jQuery实现鼠标移动切换图片动画

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>动画</title>
<style>
.img{ 1000px; height:300px; margin:0 auto; position:relative; margin-top:5px; border-radius:10px; overflow:hidden;}
.img-0{ widt:1000px; height:300px; position:absolute; z-index:21; }
.img-1{ widt:1000px; height:300px; position:absolute; z-index:10; display:none}
.img-2{ 1000px; height:300px; position:absolute; z-index:15; display:none}
.img-3{ 1000px; height:300px; position:absolute; z-index:20; display:none}
.img-4{ 960px; height:70px; position:relative;  z-index:22; border:1px solid #CCC; border-radius:10px;
margin-top:229px; float:left; margin-left:20px; background-color:#000; opacity:0.5; color: azure;}
.img-4v1{ 275px; height:70px; position:relative; float:left; border-left: 1px solid #CCC; line-height:70px;
 text-align:center; font-size:18px;}
 .img-4v1:hover{ cursor:pointer;}
</style>
</head>

<body>

<div class="img">
         <div class="img-0" id="oo"><img  src="../img/cn-1.jpg"/></div>
         <div class="img-1" id="a" ><img  src="../img/cn-1.jpg"/></div>
        <div class="img-2" id="b" ><img  src="../img/cn-2.jpg"/></div>
        <div class="img-3" id="c" ><img  src="../img/cn-3.jpg"/></div>
        <div class="img-4">
                <div  id="img-a" class="img-4v1" style="margin-left:68px">》移动到我</div>
                <div id="img-b" class="img-4v1" onmouseover="">》移动到我</div>
                <div id="img-c" class="img-4v1" style="border-right:1px solid #CCC">》移动到我</div>
        </div>
 </div>
</body>
</html>
<script type="application/javascript" src="../JS/jquery-3.2.0.js" >

</script>
<script>
$(document).ready(function(){
  $("#img-a").mouseenter(function(){ /* 鼠标移动到DIV上的效果*/
     $("#a").fadeIn();  /*    淡入ID为A的div*/
     $("#oo").hide()   /* 隐藏ID为OO的DIV    */
  });
});
$("#img-a").mouseleave(function(){ /* 鼠标离开DIV上的效果*/
    $("#a").fadeOut();     /*    淡出ID为A的div*/
     $("#oo").show()        /* 显视ID为OO的DIV    */
  });
$(document).ready(function(){  
  $("#img-b").mouseenter(function(){
     $("#b").fadeIn();
     $("#oo").hide()
  });
});
$("#img-b").mouseleave(function(){
    $("#b").fadeOut();
    $("#oo").show()
  });
$(document).ready(function(){
  $("#img-c").mouseenter(function(){
    
     $("#oo").hide()
     $("#c").fadeIn();
  });
});
$("#img-c").mouseleave(function(){
    $("#c").fadeOut();
    $("#oo").show()
  });
</script>
原文地址:https://www.cnblogs.com/yi11/p/6669058.html