我在我的网站中做了一个导航栏作为标签,我使用onlink identity来指定当前标签具有某些特征。我的问题是,当我更改选项卡时,我不知道如何将前一个选项卡 ID 设置为无,将当前选项卡设置为 onlink。
这是导航条码:
<div id="indNavBar">
<div id="indHolder">
<ul>
<li><a onclick="DisplayDIV('IndPage');HideDIV('DoubleInd')" id="onlink">Single Indicator</a></li>
<li><a onclick="DisplayDIV('DoubleInd');HideDIV('IndPage');">Double Indicators</a></li>
</ul>
</div>
</div>
有一种简单的方法,但它有点愚蠢,就是将每个当前选项卡作为一个整体页面,当我单击另一个选项卡时,它只是给出被单击的选项卡的 url,该 url 将转到具有指定 onlink id 的页面,但是这个需要重新加载整个页面,这就是我寻求更好解决方案的原因。
最佳答案
你可以通过在javascript方法中传递this
来获取被点击的控件
onclick="DisplayDIV('IndPage', this);
function DisplayDIV(IndPage, sourceObj)
{
alert(sourceObj.id);
}
关于javascript - 动态更改 css 中的 "onlink"id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11326581/