[英]how to hide submenu after click
I'm creating a dropdown menu for mobile site 我正在为移动网站创建一个下拉菜单
http://gthost.dyndns.org/kudu/en/ http://gthost.dyndns.org/kudu/en/
when I click on My Account and click on Who we are , submenu still show,, 当我单击“ 我的帐户”并单击“我们是谁”时 ,子菜单仍显示,
I Want to hide it after I click on the link. 单击链接后,我想隐藏它。
this is JavaScript code 这是JavaScript代码
var $j = jQuery.noConflict();
$j(document).ready(function () {
$j(".account").click(function () {
var X = $j(this).attr('id');
if (X == 1) {
$j(".submenu").hide();
$j(this).attr('id', '0');
} else {
$j(".submenu").show();
$j(this).attr('id', '1');
}
});
//Mouseup textarea false
$j(".submenu").mouseup(function () {
return false
});
$j(".account").mouseup(function () {
return false
});
//Textarea without editing.
$j(document).mouseup(function () {
$j(".submenu").hide();
$j(".account").attr('id', '');
});
});
i would try using: 我会尝试使用:
$('.submenu').css({display:"none"});
instead of .hide(); 而不是.hide();
Two things strike me as odd here. 这里有两件事让我感到奇怪。
[a-z_]
etc. 为什么您的ID是整数-有效名称以[a-z_]
等开头。 Without seeing your HTML structure everyone is going to be guessing but rather than whatever you are trying to do with the ID's it looks like you could logically use jQuery.toggle
: 在没有看到您的HTML结构的情况下,每个人都会猜测,但是与其试图使用ID进行任何操作,不如尝试在逻辑上使用jQuery.toggle
:
$j(".account").click(function(){
$j(".submenu").toggle();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.