编程论坛's Archiver

iabcz 发表于 2008-3-23 12:24

求教如何显示图片

请教:
在以下代码的基础上如何让这棵树关闭时节点前显示一个图片(如:附件一),展开时节点前显示另一个图片(如:附件二)

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script Language="javaScript">
<!--
function Expand(sid){
  if (document.all(sid).style.display=="none"){
     document.all(sid).style.display="";        
  }else{
     document.all(sid).style.display="none";       
  }   
}
-->
</script>
</head>
<body bgcolor="#FAFFFF" text="#000000">
<p class="textfont"><font face="楷体_GB2312">
<div align="center">
<br>
<span onclick=Expand('fe1')>[A]</span><br>   
<div id=fe1 style=display:"none">
  ┣a1<br>
  ┣a2<br>
  ┣a3<br>
  ┗a4<br>         
</div>
<span onclick=Expand('fe2')>[B]</span><br>   
<div id=fe2 style=display:"none">
  ┣b1<br>
  ┣b2<br>
  ┣b3<br>
  ┗b4<br>         
</div>
</div>
</div>
</p>
</body>
</html>

iabcz 发表于 2008-3-23 17:00

我是一个刚学的菜鸟,高手们帮帮忙,急呀

lmhllr 发表于 2008-3-23 23:08

代码中没看到img标签....

打开和关闭时更改该img的src就行了

渚薰 发表于 2008-3-24 08:48

用css,不同的class切换不同的图片

叶飘 发表于 2008-4-9 17:47

在你的基础上改

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script Language="javaScript">
<!--
function Expand(sid,img){
  if (document.all(sid).style.display=="none"){
     document.all(sid).style.display="";  
      document.all(img).src="1.gif";      
  }else{
     document.all(sid).style.display="none";
      document.all(img).src="2.gif";           
  }   
}
-->
</script>
</head>
<body bgcolor="#FAFFFF" text="#000000">
<p class="textfont"><font face="楷体_GB2312">
<div align="center">
<br>
<img id='img1' src='1.gif'>
<span onclick=Expand('fe1','img1')>[A]</span><br>   
<div id=fe1 style=display:"none">
  ┣a1<br>
  ┣a2<br>
  ┣a3<br>
  ┗a4<br>     
</div>
<img id='img2' src='1.gif'>
<span onclick=Expand('fe2','img2')>[B]</span><br>   
<div id=fe2 style=display:"none">
  ┣b1<br>
  ┣b2<br>
  ┣b3<br>
  ┗b4<br>     
</div>
</div>
</div>
</p>
</body>
</html>

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.