做了个选项卡,放了四个按钮,然后分别用了四个Css样式
如:
<style type="text/css">
.aLink1 
{
background-image:url(Images/tab_01.gif);
width:73px;
height:27px;
cursor:pointer;
}
//-----这是第一个Button的样式,其它的类似就不写出来了
</style>
<asp:Button ID="Button1" runat="server" Text="" class="aLink1" BorderWidth="0" />
现在我想实现点击第一个Button1的时候,让它的背景图片变成另外一张,而点击第二个Button时,第一个Button变回aLink1的样式,第二个Button的图片变成另外一张,以此类推。

解决方案 »

  1.   

    <asp:Button ID="Button2" runat="server"  OnClientClick="changeBg(this);return false;" Text="backgroundImage" BorderWidth="0" />
    <asp:Button ID="Button1" runat="server"  OnClientClick="changeBg(this);return false;" Text="backgroundImage" BorderWidth="0" />
     function changeBg(active) {
    //先将所有bttton重置为初始
            document.getElementById("Button2").style.backgroundImage = '';
            document.getElementById("Button1").style.backgroundImage = '';
            active.style.backgroundImage = 'url(fin_bg2.png)';
        }
      

  2.   

    Quote: 引用 1 楼 u011096386 的回复:

    Quote:

    试了试效果,结果点击以后成为空背景了,不知道是什么地方出错了。求帮助