jQuery下拉菜单onclick [英] Jquery dropdown menu onclick
本文介绍了jQuery下拉菜单onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jquery制作一个简单的下拉菜单,但是我似乎无法使任何JavaScript正常工作.我尝试从外部调用它.我不确定是什么问题,如果您发现问题,请告诉我.谢谢.
I am trying to make a simple dropdown menu with jquery but I cant seem to get any of the javascript to work. I have tried calling it externally. I am not sure what the problem can be, if you see a problem please let me know. Thanks.
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
#container{width:978px;}
.content {
display: none;
padding-left: 5px;
left: 0px;
width: 100%;
top: 30px;
background: yellow;
}
ul{width: 100%;}
li{
float: left;
padding: 5px;
background: #e5e5e5;}
#div{
background: #9e9e9e;
height: 20px;
width: 978px;
}
br{
clear: left;
}
</style>
<script type="text/javascript">
$(function() {
$('.action').click(function() {
var name = $(this).attr("name");
var content = $('.content[name=' + name + ']');
$('.content').not(content).hide('fast');
content.slideToggle('fast');
});
});
</script>
</head>
<body>
<div id="container"><ul>
<li>
<a href="#" class="action" name="summer">summer</a>
</li>
<li>
<a href="#" class="action" name="winter">winter</a>
</li>
<li>
<a href="#" class="action" name="weather">weather</a>
</li>
</ul></div><br>
<div class="content" name="summer">
<a href="link">june</a>
<a href="link">july</a>
</div>
<div class="content" name="winter">
<a href="link">november</a>
<a href="link">december</a>
</div>
<div class="content" name="weather">
<a href="link">rain</a>
<a href="link">sun</a>
</div>
<div id="div"></div>
</body>
</html>
推荐答案
尝试SuperFish => http://users.tpg.com.au/j_birch/plugins/superfish/#getting-started
try SuperFish => http://users.tpg.com.au/j_birch/plugins/superfish/#getting-started
这篇关于jQuery下拉菜单onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文