我正在使用 Spring 3.0 + 瓷砖。我已经为所有页面创建了带有锚标记的通用菜单,并应用了相同的 css。我正在使用 Jquery 在单击菜单时动态更改菜单的 css 类。
选择菜单/链接时,将应用“selectedTab”css 类,并且对于所有普通链接,将应用“tab”css 类。我面临的问题是,每次请求/单击菜单时都会应用样式类,然后在响应之后再次取消应用。也就是说,样式在请求和响应之间保持应用。但不是在回应之后。菜单链接的代码如下:
<div id="menu" class=" mainPageLayout clearFix" style="width:980px;margin:0 auto;">
<a id="dashboard" class="selectedTab" href="dashboard.html" onclick="return changeCss('dashboard');">
<span>Dashboard</span>
</a>
<a id="projects" class="tab" href="projectscontroller.html" onclick="return changeCss('projects');">
<span>Projects</span>
</a>
<a id="milestones" class="tab" href="milestones.html" onclick="return changeCss('milestones');">
<span>Milestones</span>
</a>
<a id="tasks" class="tab" href="tasks.html" onclick="return changeCss('tasks');">
<span>Tasks</span>
</a>
<a id="discussions" class="tab" href="messages.html" onclick="return changeCss('discussions');">
<span>Discussions</span>
</a>
<a id="reports" class="tab" href="reports.html" onclick="return changeCss('reports');">
<span>Reports</span>
</a>
<a id="history" class="tab" href="projects/history.html" onclick="return changeCss('history');">
<span>History</span>
</a>
<a id="templates" class="tab" style="float: right;" href="projects/users.html" onclick="return changeCss('templates');">
<span>Project templates</span>
</a>
<a id="users" class="tab" style="float: right;" href="projects/projectTemp.html" onclick="return changeCss('users');">
<span>Users</span>
</a>
</div>
相同的Jquery是:
function changeCss(aid) { //alert(aid);
jQuery("#menu a").removeClass("selectedTab");
jQuery("#menu a").addClass("tab");
jQuery("#"+ aid).removeClass("tab");
jQuery("#" + aid).addClass("selectedTab");
}
菜单的 Css 类是:
a.selectedTab:hover, .studioTopNavigationPanel .contentSection .navigationBox a.selectedTab:active { background-color: #B8D9ED; 背景图像:url(“../images/tab_selected_bg.png”);背景位置:中心顶部;背景重复:重复-x;颜色:#333333;光标:指针;显示:块;向左飘浮; 字体大小:14px;右边距:3px;填充:5px 12px;文字装饰:无;}
.studioTopNavigationPanel .contentSection .navigationBox a.tab,
.studioTopNavigationPanel .contentSection .navigationBox a.tab:visited,
.studioTopNavigationPanel .contentSection .navigationBox a.tab:hover,
.studioTopNavigationPanel .contentSection .navigationBox a.tab:active
{
background-color: #ECF3F7;
background-image: url("../images/tab_bg.png");
background-position: center top;
background-repeat: repeat-x;
color: #333333;
cursor: pointer;
display: block;
float: left;
font-size: 14px;
margin-right: 3px;
padding: 5px 12px;
text-decoration: none;
}
.studioTopNavigationPanel .contentSection .navigationBox a.selectedTab,
.studioTopNavigationPanel .contentSection .navigationBox a.selectedTab:visited,
.studioTopNavigationPanel .contentSection .navigationBox a.selectedTab:hover,
.studioTopNavigationPanel .contentSection .navigationBox a.selectedTab:active
{
background-color: #B8D9ED;
background-image: url("../images/tab_selected_bg.png");
background-position: center top;
background-repeat: repeat-x;
color: #333333;
cursor: pointer;
display: block;
float: left;
font-size: 14px;
margin-right: 3px;
padding: 5px 12px;
text-decoration: none;
}
请告诉我哪里错了,并尽快提供适当的解决方案。