突出使用asp.net母版页选定的jQuery标签 [英] Highlighting the selected jquery tab using asp.net Master page
问题描述
我使用jQuery标签(第一,第二,第三)在我的asp.net网站,并在每一页我写了UL多asp.net页面(First.aspx,second.aspx,Third.aspx)李code。
例如,在First.aspx页我写了下面的code中的UL标签内
I am using jquery tabs(First,Second,Third) in multiple asp.net pages (First.aspx, second.aspx,Third.aspx) in my asp.net website and in each page i am writing the ul,li code. For example in the First.aspx page I am writing the following code inside the 'ul' tag
<li class="current"><a href="#First">First tab</a></li>
<li><a href="Second.aspx">Second tab</a></li>
<li><a href="Third.aspx">Third tab</a></li>
同样在second.aspx,Third.aspx页我使用的是类=当前要突出所选择的tab.Recently我们计划转移到主pages.So母版页应包含UL,李code代表tabs.But的问题是,我不知道如何类=当前应用到选定的选项卡,在主的情况下page.Could有人请帮忙吗?
Similarly in the second.aspx,Third.aspx pages i am using the Class="current" to highlight the selected tab.Recently we have planned to move to Master pages.So the master page should contain the ul,li code for the tabs.But the problem is that I do not understand how to apply the class="current" to the selected tab,in the case of the master page.Could someone please help?
先谢谢了。
推荐答案
写在你的母版页中的JavaScript功能设置选项卡上的当前类。然后,每个页面都可以调用该函数时,它的加载设置当前页面。
Write a javascript function in your master page to set the current class on a tab. Each page can then call that function when it's loaded to set the current page.
是这样的:
<li id='tab1'><a href="#First">First tab</a></li>
<li id='tab2'><a href="Second.aspx">Second tab</a></li>
<li id='tab3'><a href="Third.aspx">Third tab</a></li>
function setCurrentTab(selectedTab) {
$('li').removeClass('selected');
$('[id=selectedTab]').addClass('selected');
}
和在Second.aspx,例如:
and in Second.aspx, for example:
setCurrentTab('tab2');
这篇关于突出使用asp.net母版页选定的jQuery标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!