gpt4 book ai didi

javascript - jquery ajax 和子菜单

转载 作者:行者123 更新时间:2023-11-28 10:16:50 25 4
gpt4 key购买 nike

大家好,我第一次在这里发帖,请原谅我的英语错误!

嗯,我对 jquery 和 java 很陌生,但我日复一日地学习,我发现一个非常好的网页

http://tympanus.net/codrops/2011/03/09/animated-content-menu/

在本教程网页的演示中,您有一个菜单,当您单击它时,它会消失,并且会出现一个特定的子菜单,具体取决于您选择的菜单元素。

  1. My first question is: i know how to let the menu visible when i click on one the element but i don't know how to close a submenu by clicking on another element of the menu. In default demo you have a cross you click to remove the submenu and let visible the menu again. I hope this explanation makes sense.

  2. The second question is how when you land on the main page, show directly a submenu of one element of the menu because on default demo it land with empty content and just background.

非常感谢您的每一个回答。理查德

最佳答案

所以对于你的第一个问题,他们有这样的标记:

<ul id='menu'>
<li>
<a href="#">Menu 1</a>
<div>Content goes here</div>
</li>
<li>
<a href="#">Menu 2</a>
<div>Content goes here</div>
</li>
</ul>

你会有这样的脚本:

var anchors = $("#menu a").click(function(e){
e.preventDefault();
var clicked = this;
$(this).siblings('div').show();
anchors.filter(function(index) {
return this !== clicked;
}).siblings('div').hide();
});

要在您登陆页面时立即显示某些内容,您需要执行以下操作:

$("#menu a:first").click();

关于javascript - jquery ajax 和子菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6428889/

25 4 0
文章推荐: html - 如何将未指定宽度的 div 居中?
文章推荐: css -
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com