如何使用母版页使用jQuery做的菜单? [英] How to make menu by using Master Page with jquery?
本文介绍了如何使用母版页使用jQuery做的菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
时下读音字使一个MVC项目,我用母版页我想做出与项目菜单有活动preferences我用 $(文件)。就绪(函数(){//文档
Hi guys nowadays i m making one mvc project and i use master page i wanna make menu with items have active preferences i used $(document).ready(function() { //document
$('#tabMenu > li').click(function() { //clik
if (!$(this).hasClass('active')) { //if
$('#tabMenu > li').removeClass('active');
/
$(this).addClass('active');
} //endif
} //click
);
} //文件
);
和HTML菜单/ *
/ *微升的id =tabMenu>
<%= Html.ActionLink(家,索引,家)%>
<%= Html.ActionLink(关于,关于,家)%>
</ul>*/
这是工作,但只需1秒becoz母版页加载其菜单,所以我怎么能解决这个问题?
it is working but just 1 second becoz master page load its menu and so how can i solve this problem?
推荐答案
您的问题不是很清楚......
Your question is not very clear...
以下code工作...也许这可以帮助?
The following code works... Maybe this helps?
<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<style type="text/css">
#tabMenu li {display:block;float:left;background-color:green;}
#tabMenu li a {color:white;}
#tabMenu li.active {background-color:blue;}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#tabMenu > li').click(function() {
if (!$(this).hasClass('active')) {
$('#tabMenu > li').removeClass('active');
$(this).addClass('active');
}
});
});
</script>
</head>
<body>
<div id="menu">
<ul id="tabMenu">
<li><a href="#">MenuItem</a></li>
<li><a href="#">MenuItem</a></li>
<li><a href="#">MenuItem</a></li>
</ul>
</div>
</body>
</html>
这篇关于如何使用母版页使用jQuery做的菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文