如何通过单击侧面菜单来关闭它

时间:2018-04-05 16:51:51

标签: javascript jquery

我有一个很好的侧面菜单。打开菜单时我需要帮助用户可以通过点击它来关闭菜单。

$(document).ready(function()
{
$('#service-icon-button').click(function() {
if($(this).css("margin-left") == "480px")
{
    $('.service-menu').animate({"margin-left": '-=480'});
    $('#service-icon-button').animate({"margin-left": '-=480'});
}
else
{
    $('.service-menu').animate({"margin-left": '+=480'});
    $('#service-icon-button').animate({"margin-left": '+=480'});
}

});

});   

在jsfiddle样本下面 https://jsfiddle.net/ahmedcom/1j0wr4pL/8/

2 个答案:

答案 0 :(得分:0)

您可以使用此代码通过点击外部菜单来关闭侧边菜单

ID <- paste(1:10, LETTERS[1:10], sep = "")
var1 <- c(paste(rep("Gene", 4), 1:4, sep = ""), "Gene15 /// Gene11", 
paste(rep("Gene", 5), 6:10, sep = ""))
df <- data.frame("ID" = ID, "var1" = var1)
tomatch <- c(paste(rep("Gene", 10), 2:11, sep = ""))

want <- df[df$var1 %in% 
tomatch, ]

答案 1 :(得分:0)

您可以添加侦听器和条件以检查菜单是否已打开:

<asp:ListItem Value="4" onclick="CheckAllConditions();" CssClass="new-item"> 
    I understand and agree the statement!  
</asp:ListItem>