//很简单也很优美的下拉菜单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="../../jquery-1.7.1.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
//找到所有span,并且当点击span以后控制下一个元素div的显示和隐藏
$("span").click(function(){
$(this).next().toggle("slow");
});
//初始化隐藏状态
$(".menu").each(function(index,domEle){
$(domEle).toggle();
});
});
</script>
</head>
<body>
<div>
<span>数码产品</span>
<div class="menu">
<a href="#">数码相机1</a><br>
<a href="#">数码相机2</a><br>
<a href="#">数码相机3</a><br>
</div><br>
<span>家用电器</span>
<div class="menu">
<a href="#">手电筒1</a><br>
<a href="#">手电筒2</a><br>
<a href="#">手电筒3</a><br>
</div><br>
<span>衣帽服饰</span>
<div class="menu">
<a href="#">大衣1</a><br>
<a href="#">大衣2</a><br>
<a href="#">大衣3</a><br>
</div>
</div>
</body>
</html>
jquery实现很优美的下拉菜单
最新推荐文章于 2024-08-22 14:32:34 发布