- <html>
- <head>
- <script type="text/javascript">
- <!--
- function one(){
- document.getElementById('ok').style.background='url(http://d.lanrentuku.com/down/png/1205/angrybirds.jpg)';
- }
- function two(){
- document.getElementById('ok').style.background='url(http://d.lanrentuku.com/down/png/1110/angry_birds.jpg)';
- }
- function first(){
- document.yes.src='http://d.lanrentuku.com/down/png/1205/angrybirds.jpg';
- }
- function second(){
- document.yes.src='http://d.lanrentuku.com/down/png/1110/angry_birds.jpg';
- }
- //-->
- </script>
- </head>
- <body>
- <div id="ok" onMouseover="one()" onMouseout="two()" style="height:150px;width:550px;border:1px solid #ccc;background:#ddd">通过获取id变换</div>
- <hr />
- <a href="#">
- <img src="http://www.baidu.com/img/baidu_jgylogo3.gif" name="yes" onmouseOver="first()" onmouseOut="second()" border="0" />
- </a>
- </body>
- </html>
转载于:https://blog.51cto.com/xuqin/948828