HTML代码:
<! DOCTYPE html> <head> <title></title> <meat charset="utf-8"> </head> <body> <div class="toggle"> <img src="images/"> <img src="images/"> <img src="images/"> </div> </body> </html>
CSS样式表代码:
div.toggle img{width:200px;height:180px; float:right}; body{background-image:url()};
javascript代码:
var toggle=document.getElementsByTagName("img"); var body=document.getElementsByTagName("body") ; toggle.onclick=function(){ body[0].style.backgroundImage="url(this.getAttribute(url))"; }
时间: 2024-10-07 12:58:51