随笔 - 28, 文章 - 0, 评论 - 3, 引用 - 0
数据加载中……

js点击切换图片

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title></title>
 <script type="text/javascript" language="javascript" >
 <!--
  window.onload=function(){
 document.getElementById("box").style.backgroundImage="url(1.jpg)";
 var box=document.getElementById("box");
 box.onclick=function(){
 //alert(box.style.backgroundImage);
 //alert(typeof(box.style.backgroundImage));
 if(box.style.backgroundImage.indexOf("1.jpg")!=-1)
 {box.style.backgroundImage="url(2.jpg)";}else {box.style.backgroundImage="url(1.jpg)"}
 }
  }
 -->
 </script>
 <style type="text/css">
 <!--
 #box{width:800px;height:600px;}
 -->
 </style>
</head
&lt;body>
<div id="box">
&nbsp;
</div>
</body>
</html>

posted on 2010-03-22 11:06 Angle Wang 阅读(6441) 评论(1)  编辑  收藏 所属分类: CSS

评论

# re: js点击切换图片  回复  更多评论   

谢谢,试试
2011-02-25 16:33 | 淘宝网女装

只有注册用户登录后才能发表评论。


网站导航: