日期:2014-05-16 浏览次数:20457 次
.tab{list-style-type:none;float:left; width:100px; height:23px; text-align:center;overflow:hidden; margin:2px ;background: url(../images/lrtk.png) no-repeat 0 -108px;border:1px solid black;} <ul> <li id="tab1" class="tab" onclick ="change_option(4,1)"><a href="#fragment-1"><asp:Literal ID="LtDESC" runat="server">简介</asp:Literal></a></li> <li id="tab2" class="tab" onclick ="change_option(4,2)"><a href="#fragment-2"><asp:Literal ID="LtParameters" runat="server">详细参数</asp:Literal></a></li> <li id="tab3" class="tab" onclick ="change_option(4,3)"><a href="#fragment-3"><asp:Literal ID="LtPacking" runat="server">包装清单</asp:Literal></a></li> <li id="tab4" class="tab" onclick="TOProductsReply()"><a href="#fragment-4"><asp:Literal ID="LtTalking" runat="server">产品评论</asp:Literal></a></li> </ul>
function change_option(a,b) { for (var i = 1; i <= a; i++) { document.getElementById('fragment' + i).style.display = 'none'; document.getElementById('tab'+i).style.background='url(images/MenuRed.png)'; } document.getElementById('fragment' + b).style.display = 'block'; document.getElementById('tab'+b).style.background='url(images/MenuRed.png)'; // document.getElementById('tab'+b).className="bg" } 点击的时候将当前的背景图换一个。就是没换。style.display = 'none'就起作用