<img src="images/newtop2_02.gif"  onclick="this.src='images/newtop2_02.gif'?this.src='images/newtop1_02.gif':this.src='images/newtop2_02.gif'" id="image2"/>
点击第一次还可以换  第二次就不可换了   汗颜啊

 http://www.ponpa.com/index.php上那样  点击换图片  点击其他的按钮的时候   其他的恢复原状
怎么做的请教了 请大家帮帮忙
     
  

解决方案 »

  1.   

    少了一个等号
    【this.src='images/newtop2_02.gif'】改成【this.src=='images/newtop2_02.gif'】
      

  2.   

    <table>   
      <tr   style="background-color:#f00000"   onclick="doselect(1);">   
      <td   ><img   id="img1"   src="images/newtop2_02.gif"   ></td>   
      <td   >测试</td>   
      <td   >test</td>   
      </tr>
      </table>   
      <script   language=javascript>   
      function   doselect(idx){   
      var   obj=document.getElementById("img"+idx);   
      var   imgsrc=obj.src.split("/");   
      if(imgsrc[imgsrc.length-1]=="newtop2_02.gif") imgsrc[imgsrc.length-1]="newtop1_02.gif";   
      else   imgsrc[imgsrc.length-1]="newtop2_02.gif";   
      obj.src=imgsrc.join("/");   
      alert(obj.src);   
      }   
      </script>
      

  3.   

    给你写了一个超简单的
    <SCRIPT LANGUAGE="JavaScript">
    var imgArr=new Array();
    imgArr[0]="http://avatar.profile.csdn.net/3/8/7/2_wx8849.jpg";
    imgArr[1]="http://avatar.profile.csdn.net/1/8/D/2_tangling365936812.jpg";
    imgArr[2]="http://c.csdn.net/bbs/t/5/i/pic_logo.gif";
    function a(o){
    var index=o.getAttribute("index");

    if(index>-1 && index+1<imgArr.length){
    o.src=imgArr[index+1]
    o.setAttribute("index",index+1);
    }
    else{
    o.src=imgArr[0];
    o.setAttribute("index",0);
    }

    }
    </SCRIPT><img src="http://avatar.profile.csdn.net/3/8/7/2_wx8849.jpg" onclick="a(this)"/>
      

  4.   

     var img_idx=0;
                var img_list=new Array("c:\\1.jpg","c:\\2.jpg");
                function next_img(){
                    img_idx++;
                    img_idx%=img_list.length;
                    img_list[img_idx];
                    this.src=img_list[img_idx];
                }
      

  5.   


    <Script>
     function show()
       {
       if(document.getElementById("image2").src='images/newtop2_02.gif')
         {
           document.getElementById("image2").src='images/newtop1_02.gif'
         }
         else
          {
           document.getElementById("image2").src='images/newtop2_02.gif'
          }
          }
    </Script>
    <img src="images/newtop2_02.gif"  onclick="show()" id="image2"/>