鼠标经过是改变背景图片。经过另一个区域是换回来。大体代码如下。感觉好繁琐。很多地方要用,帮忙精简

2020-05-29 教育 77阅读



JavaScript拖拉缩放效<&><br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" &> <br><style type="text/css"><br />.p{<br /> background-image:url(163/_notes/danhan4.png);<br /> width:88px;<br /> background-repeat:no-repeat;<br /> line-height:25px;<br /> display: block;<br />}<br />.p2{<br /> background-image:url(163/_notes/danhang3.png);<br /> width:88px;<br /> background-repeat:no-repeat;<br /> line-height:25px;<br /> display: block;<br />}<br /></style><br /><script type="text/javascript"><br />function mouseover(id)<br />{<br />//每次调用该函数都重新赋予背景图片如下<br /> document.getElementById('b1').style.backgroundImage="url(163/_notes/danhang3.png)";<br /> document.getElementById('b2').style.backgroundImage="url(163/_notes/danhang3.png)";<br /> document.getElementById('b3').style.backgroundImage="url(163/_notes/danhang3.png)";<br /> document.getElementById('b4').style.backgroundImage="url(163/_notes/danhang3.png)";<br /> //经过那个Id,将那个对象的背景图片变更<br /> document.getElementById(id).style.backgroundImage="url(163/_notes/danhan4.png)";<br /> <br />}<br /></script><br /><body><br /><div><br /><br /><li class="p" onMouseOver="mouseover(b1)" id="b1">4444444</li><br /><li class="p2" onMouseOver="mouseover(b2)" id="b2">5555555</li><br /><li class="p2" onMouseOver="mouseover(b3)" id="b3">6666666</li><br /><li class="p2" onMouseOver="mouseover(b4)" id="b4">4444444</li><br /></div><br /></body><br /></head><br /></head></style></&>
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com