Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqueryshow&;隐藏菜单基础_Javascript_Jquery_Html - Fatal编程技术网

Javascript jqueryshow&;隐藏菜单基础

Javascript jqueryshow&;隐藏菜单基础,javascript,jquery,html,Javascript,Jquery,Html,我正在尝试制作一个带有点击功能和隐藏与显示基本功能的双功能菜单,但我不明白为什么不工作,你能帮我吗?这是我的剧本: $(document).ready(function() { $('#work').click(function(event){ $(this).addClass("activado"); // add active class $("#other,#contacto").removeClass("activado"); // remove active clas

我正在尝试制作一个带有点击功能和隐藏与显示基本功能的双功能菜单,但我不明白为什么不工作,你能帮我吗?这是我的剧本:

$(document).ready(function() {

$('#work').click(function(event){
    $(this).addClass("activado"); // add active class
    $("#other,#contacto").removeClass("activado"); // remove active class
    $("#menuother").hide();
    $("#menuwork").show();
});

$('#other').click(function(event){
    $(this).addClass("activado");
    $("#work,#contacto").removeClass("activado");
    $("#menuwork").hide();
    $("#menuother").show();
});

$('#contacto').click(function(event){
    $(this).addClass("activado");
    $("#work,#other").removeClass("activado");
    $("#menuwork").hide();
});
});
我的html是非常基本的,我认为你不需要它,脚本本身就说明了这一点。活动类正在工作,但隐藏和显示未工作

非常感谢

//编辑 顺便说一下,我正在用css隐藏菜单

//编辑添加html

<a href="#" id="work" class="inactivo">TopMenu</a>
<a href="#" id="other" class="inactivo">TopMenu</a>
<a href="#" id="contacto" class="inactivo">TopMenu</a>

<div id="#menuwork">
<a href="#" id="SubMenu1" class="inactivo">SubMenu</a>
<a href="#" id="SubMenu2" class="inactivo">SubMenu</a>
<a href="#" id="SubMenu3" class="inactivo">SubMenu</a>
</div>

<div id="#menuother">
<a href="#" id="SubMenu4" class="inactivo">SubMenu</a>
<a href="#" id="SubMenu5" class="inactivo">SubMenu</a>
<a href="#" id="SubMenu6" class="inactivo">SubMenu</a>
</div>

对于初学者,从
div
元素中的ID中删除
#
。例如:

<div id="#menuwork">

应该是:

<div id="menuwork">

这不是创建菜单的方式。。嗯


您无需为active和inactive创建类即可完成此操作


可能显示了菜单,但没有显示菜单的大小?菜单的HTML和CSS是什么?已经检查过了,我还添加了一个边框,看看它是否有效,没有运气。我将使用html和css。我们需要html和css。复制所有内容,保存并提供链接。这毫无意义。。天啊,这就是问题所在,我很抱歉,我现在觉得自己像个白痴。非常感谢。@kinduff:没问题!这发生在我们所有人身上!