多个图片使用onMouseOver跟onMouseOut时一起改变了 5
移动到一个照片上两个都改变了,可是我只想一个变怎么办。。javascript的程序。。因为要的图片比较多就用数组做了<scripttype="text/javascrip...
移动到一个照片上两个都改变了,可是我只想一个变怎么办。。
javascript的程序。。因为要的图片比较多就用数组做了
<script type="text/javascript">
var bb=['b1','b2','b3','b4','b5','b6','b7','b8','b9','b10','b11','b12','b13','b14','b15','b16','b17','b18','b19','b20','b21','b22','b23','b24','b25','b26','b27'];
var file1=["rj/1.png","rj/2.png","rj/3.png","rj/4.png","rj/5.png","rj/6.png","rj/7.png","rj/8.png","rj/9.png","rj/10.png","rj/11.png","rj/12.png","rj/13.png","rj/14.png","rj/15.png","rj/16.png","rj/17.png","rj/18.png","rj/19.png","rj/20.png","rj/21.png","rj/22.png","rj/23.png","rj/24.png","rj/25.png","rj/26.png","rj/27.png",];
file2=["rj/1_副本.png","rj/2_副本.png","rj/3_副本.png","rj/4_副本.png","rj/5_副本.png","rj/6_副本.png","rj/7_副本.png","rj/8_副本.png","rj/9_副本.png","rj/10_副本.png","rj/11_副本.png","rj/12_副本.png","rj/13_副本.png","rj/14_副本.png","rj/15_副本.png","rj/16_副本.png","rj/17_副本.png","rj/18_副本.png","rj/19_副本.png","rj/20_副本.png","rj/21_副本.png","rj/22_副本.png","rj/23_副本.png","rj/24_副本.png","rj/25_副本.png","rj/26_副本.png","rj/27_副本.png"];
//mouseOut设置鼠标离开时
function mouseOut(){
for(var i=0;i<27;i++){
document.getElementById(bb[i]).src=file2[i];
document.getElementById(bb[i]).style.width="50px";
}
}
function mouseOver(){
for(var i=0;i<27;i++){
document.getElementById(bb[i]).src=file1[i];
document.getElementById(bb[i]).style.width="50px";
}
}
</script> 展开
javascript的程序。。因为要的图片比较多就用数组做了
<script type="text/javascript">
var bb=['b1','b2','b3','b4','b5','b6','b7','b8','b9','b10','b11','b12','b13','b14','b15','b16','b17','b18','b19','b20','b21','b22','b23','b24','b25','b26','b27'];
var file1=["rj/1.png","rj/2.png","rj/3.png","rj/4.png","rj/5.png","rj/6.png","rj/7.png","rj/8.png","rj/9.png","rj/10.png","rj/11.png","rj/12.png","rj/13.png","rj/14.png","rj/15.png","rj/16.png","rj/17.png","rj/18.png","rj/19.png","rj/20.png","rj/21.png","rj/22.png","rj/23.png","rj/24.png","rj/25.png","rj/26.png","rj/27.png",];
file2=["rj/1_副本.png","rj/2_副本.png","rj/3_副本.png","rj/4_副本.png","rj/5_副本.png","rj/6_副本.png","rj/7_副本.png","rj/8_副本.png","rj/9_副本.png","rj/10_副本.png","rj/11_副本.png","rj/12_副本.png","rj/13_副本.png","rj/14_副本.png","rj/15_副本.png","rj/16_副本.png","rj/17_副本.png","rj/18_副本.png","rj/19_副本.png","rj/20_副本.png","rj/21_副本.png","rj/22_副本.png","rj/23_副本.png","rj/24_副本.png","rj/25_副本.png","rj/26_副本.png","rj/27_副本.png"];
//mouseOut设置鼠标离开时
function mouseOut(){
for(var i=0;i<27;i++){
document.getElementById(bb[i]).src=file2[i];
document.getElementById(bb[i]).style.width="50px";
}
}
function mouseOver(){
for(var i=0;i<27;i++){
document.getElementById(bb[i]).src=file1[i];
document.getElementById(bb[i]).style.width="50px";
}
}
</script> 展开
1个回答
展开全部
//jquery写的 each 当前 被鼠标划过时
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){
var a;
$("img").each(function(){
$(this).bind("mouseover",function(){
a=$(this).index();
$(this).attr("src",file1[a]);
}).bind("mouseout",function(){
$(this).attr("src",file2[a]);
});
});
})
</script>
看你的代码 好像你想在鼠标划过的时候去除当前图片的阴影层啊,没必要搞两个图片啊,来个遮罩层定位到图片上,鼠标划过改变当前遮罩层的透明度(opacity)。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询