如何更改< a>的CSS类使用Jquery/Javascript标记 [英] How to change CSS class of <a> tag using Jquery/Javascript
本文介绍了如何更改< a>的CSS类使用Jquery/Javascript标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图根据所选页面更改仪表板上选项卡的类别. 我在仪表板上有3个标签,例如
I am trying to change the class of a tab on the dashboard depending upon the page selected. I have 3 tabs in the dashboard like
<div>
<ul class="menu">
<li class="MenuDashboard"><a href="#" >Dashboard</a></li>
<li class="MenuSearch"><a href="#">Search</a></li>
<li class="MenuAccountSetup"><a href="#">Account Set up</a></li>
</ul>
</div>
现在,当我选择特定标签时,我想突出显示该标签.默认情况下,仪表板"标签应突出显示.我有一个称为当前"的样式类,该类突出显示了选项卡. 请告知.
Now I want to highlight the tab when I select that particular tab. By default the 'Dashboard' tab should be highlighted. I have a style class called "current" which highlights the tab. Please advise.
推荐答案
这应该有效:
$('.menu li').click(function() {
$(this).addClass('current').siblings().removeClass('current');
});
// Clicks on the first menu item to style it
$('.menu li').eq(0).click();
这篇关于如何更改< a>的CSS类使用Jquery/Javascript标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文