JS鼠标经过换图案例
以前做JS鼠标经过后换图都是用Macromedia Dreamweaver 8自己带的换图功能,还有一种很简单的方法就是这样(<img src="1.jpg" onmouseover="this.src='2.jpg' " onmouseout="this.src='1.jpg'">)这两种方法都很简单,但听说那种方法是当鼠标经过时会访问一次服务器,如果是流量特大的网站用那种方法的话就会使服务器产生很大的负担,所以就又写了以下这种方法,也很简单主要是不会有上面两种方法的缺点。下面我就来说说这种方法
JS部分是这么写的:
function Show_God(Tab_num)
{
document.getElementById("a_" + Tab_num + "1").style.display = "none";
document.getElementById("a_" + Tab_num + "2").style.display = "block";
}
function Show_Dea(Dab_num)
{
document.getElementById("a_" + Dab_num + "1").style.display = "block";
document.getElementById("a_" + Dab_num + "2").style.display = "none";
}
这是CSS部分:(这个和换图没有直接的关系,只是样试设置)
ul, li {list-style-type:none;margin:0;padding:0;}
.togjbannrd{width:925px; padding-left:25px; margin-bottom:15px; padding-bottom:10px; border-bottom:1px solid #E5E5E5;}
.togjbannrd ul{width:925px; float:left;}
.togjbannrd li{width:182px; height:42px; float:left;}
.togjbannrd img {border:1px solid #ccc;}
这是DIV代码部分:
<div class="togjbannrd">
<ul>
<li onmouseover="Show_God(1)" onmouseOut="Show_Dea(1)"><a href="#" target="_blank"><img id="a_11" src="images/20090603.gif" border="0" /><img id="a_12" style="display:none;" src="images/20090602.gif" border="0" /></a></li>
<li onmouseover="Show_God(2)" onmouseOut="Show_Dea(2)"><a href="#" target="_blank"><img id="a_21" src="images/20090603.gif" border="0" /><img id="a_22" style="display:none;" src="images/20090602.gif" border="0" /></a></li>
<li onmouseover="Show_God(3)" onmouseOut="Show_Dea(3)"><a href="#" target="_blank"><img id="a_31" src="images/20090603.gif" border="0" /><img id="a_32" style="display:none;" src="images/20090602.gif" border="0" /></a></li>
</ul>
</div>
- js设置图片或文字自动左右滚动控制,鼠标经过停留
- 【JavaScript】js可以直接使用的鼠标经过切换图片
- JS 鼠标经过显示大图
- JQuery鼠标经过弹出气泡框的js特效效果
- JS实现鼠标经过用户头像显示资料卡的效果,可点击
- js实现鼠标经过表格行变色的方法
- js实现鼠标经过表格行变色的方法
- 3.3 JS 表单自动获得焦点&&鼠标经过全选表单内容
- js 鼠标经过显示隐藏效果实例
- 利用JS实现基本的图片轮播功能,包括鼠标的经过事件
- js和css两种实现鼠标经过图片时显示透明框的遮罩条文字
- js-鼠标经过或点击在鼠标当前位置弹出DIV层
- JS实现侧边栏鼠标经过弹出框+缓冲效果
- 表格鼠标经过有底色的js
- 淘宝商城首页鼠标经过整个区域图片变暗变亮的JS特效代码
- 鼠标经过显示二级菜单的js特效
- js-鼠标经过显示下拉菜单
- 关于js鼠标滚轮放大缩小图片案例
- js--表格操纵之 鼠标经过整行变色
- js定义鼠标经过变换图片