永发信息网

JS +div图片转换

答案:4  悬赏:80  手机版
解决时间 2021-05-08 02:08
  • 提问者网友:趣果有间
  • 2021-05-07 04:02
<script language="javascript">
function change()
{
document.getElementById("").src="新图";
}

function rechange()
{
document.getElementById("").src="旧图";
}
</script>
<div src="新图" onMouseOver="change()" id="" onMouseOut="rechange()">
</div>
最佳答案
  • 五星知识达人网友:掌灯师
  • 2021-05-07 04:27

恩, 很不错, 不知道你有什么问题

全部回答
  • 1楼网友:老鼠爱大米
  • 2021-05-07 07:35

你要的是不是这种效果

<script language="javascript"> function change(imgobj) { imgobj.src=" http://www.baidu.com/img/baidu_logo.gif"; }

function rechange(imgobj) { imgobj.src=" http://cache.soso.com/wenwen/i/wenwen_logo.gif"; } </script> <div src="新图" onMouseOver="change(imgtu)" id="" onMouseOut="rechange(imgtu)"> <img src=" http://cache.soso.com/wenwen/i/wenwen_logo.gif" id="imgtu"/> </div>

  • 2楼网友:动情书生
  • 2021-05-07 06:07

document.getElementById你要做什么

DIV有src属性么..貌似没有吧

  • 3楼网友:走死在岁月里
  • 2021-05-07 05:52
div+css学习笔记22(用div实现向左无缝滚动图片效果)JavaScript实现走马灯效果[无缝连接、循环滚动] 无缝跑马灯效果 以下代码在IE6、Firefox+Win2k环境下测试通过 网页走马灯连续循环滚动 废话少说,代码贴出来: <div id="imgmarquee" style="OVERFLOW: hidden; WIDTH: 580px; align: left; background-color:#0099CC;"> <div style="width:1200px"> <!--id="marquePic1"里面的宽度一定要大于id="imgmarquee"的宽度才能看到效果 width:600px;>WIDTH: 580px; 大的div宽度要为span的两倍才可以,不然会换行width:1200px zdz的作品,流风的作品 --> <span id="marquePic1" style="width:600px; background-color:#990033;"> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> <img src="../images/dialog/4.gif" /> </span> <span id="marquePic2" style="width:600px;background-color:#990033;"></span> </div> </div> <script type="text/javascript"> var imgmarquee = document.getElementById('imgmarquee'); var marquePic2 = document.getElementById('marquePic2'); var marquePic1 = document.getElementById('marquePic1'); var speed=10;//控制移动的速度,数越大越慢 marquePic2.innerHTML=marquePic1.innerHTML;//把marquePic1的内容复制到marquePic2里面 function Marquee(){ if(imgmarquee.scrollLeft>=marquePic1.scrollWidth){ imgmarquee.scrollLeft=0; }else{ //demo.scrollLeft++; imgmarquee.scrollLeft++; } } var marqueetemp=setInterval(Marquee,speed); imgmarquee.onmouseover=function() {clearInterval(marqueetemp)} //鼠标移到上面停止并清除计数 imgmarquee.onmouseout=function() {marqueetemp=setInterval(Marquee,speed)} //鼠标离开重新计数 </script> ------------ 参考资料(向右,向上,向下代码同理,只是控制的js不同而已,把下面的id改成对应的就ok了) ------------ 向右 ------------ <script language="javascript" type="text/javascript"> <!-- var demo = document.getElementById("demo"); var demo1 = document.getElementById("demo1"); var demo2 = document.getElementById("demo2"); var speed=10; //数值越大滚动速度越慢 demo2.innerHTML = demo1.innerHTML; demo.scrollLeft = demo.scrollWidth; function Marquee(){ if(demo.scrollLeft<=0) demo.scrollLeft+=demo2.offsetWidth else{ demo.scrollLeft-- } } var MyMar = setInterval(Marquee,speed) demo.onmouseover = function(){clearInterval(MyMar)} demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)} --> </script> ------------- 向下 ------------- <script language="javascript" type="text/javascript"> <!-- var demo = document.getElementById("demo"); var demo1 = document.getElementById("demo1"); var demo2 = document.getElementById("demo2"); var speed=10; //数值越大滚动速度越慢 demo2.innerHTML = demo1.innerHTML; demo.scrollTop = demo.scrollHeight; function Marquee(){ if(demo1.offsetTop-demo.scrollTop>=0) demo.scrollTop+=demo2.offsetHeight else{ demo.scrollTop-- } } var MyMar = setInterval(Marquee,speed); demo.onmouseover = function(){clearInterval(MyMar)} demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)} --> </script> ----------- 向上 ----------- <script language="javascript" type="text/javascript"> <!-- var demo = document.getElementById("demo"); var demo1 = document.getElementById("demo1"); var demo2 = document.getElementById("demo2"); var speed=10; //滚动速度值,值越大速度越慢 demo2.innerHTML = demo1.innerHTML //克隆demo2为demo1 function Marquee(){ if(demo2.offsetTop-demo.scrollTop<=0) //当滚动至demo1与demo2交界时 demo.scrollTop-=demo1.offsetHeight //demo跳到最顶端 else{ demo.scrollTop++ } } var MyMar = setInterval(Marquee,speed); //设置定时器 demo.onmouseover = function(){clearInterval(MyMar)} //鼠标经过时清除定时器达到滚动停止的目的 demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)} //鼠标移开时重设定时器 --> </script> <DIV id=demo_1 style="OVERFLOW: hidden; HEIGHT: 136px"> <DIV id=demo1_1> <div id=gleft> <a href=""><img src="" border="0" width=150 height="120"/></a> </div> <div id=gleft> <a href=""><img src="" border="0" width=150 height="120"/></a> </div> <div id=gleft> <a href=""><img src="" border="0" width=150 height="120"/></a> </div> <div id=gleft> <a href=""><img src="" border="0" width=150 height="120"/></a> </div> </DIV> <DIV id=demo2_1></DIV></DIV> <SCRIPT> var speed=25 demo2.innerHTML=demo1.innerHTML function Marquee(){ if(demo2.offsetWidth-demo.scrollLeft<=0) demo.scrollLeft-=demo1.offsetWidth else{ demo.scrollLeft++ } } var MyMar=setInterval(Marquee,speed) demo.onmouseover=function() {clearInterval(MyMar)} demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} </SCRIPT> 其中<div id=gleft>这里的gleft的样式你自己定义下就OK了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯