我正在尝试制作一个doble菜单,点击功能和隐藏和显示基础,但我不明白为什么不工作,你能帮帮我吗?这是我的剧本:
$(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>
答案 0 :(得分:4)
对于初学者,请从#
元素中的ID中删除div
。例如:
<div id="#menuwork">
应该是:
<div id="menuwork">
答案 1 :(得分:1)
这不是你创建菜单的方式..呃......
答案 2 :(得分:0)
您可以执行此操作,而无需为活动和非活动
创建类