2016-08-24 129 views
0

我在我的页面左侧有手风琴菜单。今天,我注意到访问量急剧下降,试图找到问题,我发现我的菜单3周前停止工作。它用于当我点击箭头时下拉,当我点击具有子菜单的菜单时,它仍然打开,并在父菜单处突出显示。现在,当我点击产品时,我的菜单不再崩溃。试图改变类和链接到最新版本的jQuery,但没有奏效。 请帮助我,或者是什么导致它突然停止工作?下拉菜单停止工作

My site with not working menu

的Javascript

<script src="http://code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"> 
(function($) { 
$(document).ready(function() { 
    $('#left li.menu-item-has-children').prepend('<span class="holder"></span>'); 
    $('#left li.menu-item-has-children > .holder').on('click', this, function(){ 
     var element = $(this).parent('li'); 
     if (element.hasClass('open')) { 
      element.removeClass('open'); 
      element.find('li').removeClass('open'); 
      element.find('ul').slideUp(); 
     } 
     else { 
      element.addClass('open'); 
      element.children('ul').slideDown(); 
      element.siblings('li').children('ul').slideUp(); 
      element.siblings('li').removeClass('open'); 
      element.siblings('li').find('li').removeClass('open'); 
      element.siblings('li').find('ul').slideUp(); 
     } 
    }); 
$('#left li.current-menu-item').addClass('open').children('ul').slideDown(); 
    }); 
})(jQuery); 
</script> 

CSS

.uslugi >a{ 
    color: #F00 !important; 
    font-size:16px !important; 
    border-bottom: 1px solid rgba(0, 0, 0, 0.04); 
} 
#left, 
#left ul, 
#left ul li, 
#left ul li a { 
    padding: 0; 
    list-style: none; 
    line-height: 1.5; 
    display: block; 
    position: relative; 
    cursor: pointer; 
    text-decoration: none; 
    color: #515151; 
    margin:0; 
    font-family: "Trebuchet MS", Helvetica, sans-serif; 
    font-size: 16px; 
} 
#left ul li a:hover{ 
color: #000; 
background-color: rgba(47, 139, 182, 0.1); 
} 
.widget.widget_nav_menu li:before{ 
    display: none; 
} 

#main-wrapper .widget li:hover{ 
    background:none; 
} 
#left ul ul { 
    display: none; 
    margin: 0 10px; 
} 
#left ul ul li a { 
    cursor: pointer; 
padding: 0 5px; 
z-index: 1; 
color: #344E83; 
background: -moz-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%); 
background: -webkit-gradient(right top, left top, color-stop(0%, rgba(255,255,255,1)), color-stop(98%, rgba(255,255,255,0.91)), color-stop(100%, rgba(184,238,255,0.81))); 
background: -webkit-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%); 
background: -o-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%); 
background: -ms-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%); 
background: linear-gradient(to left, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%); 
} 
#left .menu-item-has-children > a:after { 
    content: ""; 
border-right: 10px solid transparent; 
border-left: 10px solid transparent; 
margin: 10px 13px 0 0; 
border-top: 6px solid #5F5F5F; 
position: absolute; 
right: 0; 
top: 0; 
    } 
.holder{ 
border: 1px solid rgba(0, 0, 0, 0.14); 
padding: 11px 26px; 
z-index: 8; 
position: absolute; 
margin: 1px -3px 0 0; 
right: 0; 
background: none; 
    } 
.holder:hover { 
    background: rgba(47, 139, 182, 0.1); 
} 
#left ul li.open > a, 
#left ul li.active > a, 
#left ul ul li:hover > a, 
#left ul ul li.open > a, 
#left ul ul li.active > a, 
.current-page-ancestor a { 
color: #4686E6; 
background-color: rgba(47, 139, 182, 0.2); 
} 
#left ul ul li:first-child > a { 
    box-shadow: none; 
} 

#left ul ul ul li a { 
    padding-left: 30px; 
} 
@media (min-width:768px) and (max-width:979px){ 
     .span3{ 
     width:186px; 
     margin-left:0; 
    } 
} 
+0

你能否提供html?你的意思是左边的菜单,是吗? –

+0

是的,它在左边。 – KwS

回答

2

你的脚本是不是因为工作,HTML标记问题(script标签),检查它与萤火虫>脚本>在第444行附近内联:

<script src="http://code.jquery.com/jquery-3.1.0.min.js" type="text/javascript">(function($) { $(document).ready(function() {

你应该关闭脚本标签,然后打开一个新问题:

<script src="http://code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"</script><script>(function($) { $(document).ready(function() { .... </script>

+0

感谢您的关注,我已经将它从单独的块更改为像您指出的那样,但忘记再次更改它。现在,我确实喜欢你说的,但它仍然不起作用。当我点击页面中心的产品时,它只会突出显示父菜单,但不像以前那样折叠。 – KwS

+0

尝试将

0

看来你的选择没有任何比赛:

#left li.menu-item-has-children > .holder 

我没有看到您的持有人类内l i.menu-item-has-children定义。它看起来像你应该添加一个持有人类到您的<a>元素。

请让我知道它是否有帮助。

+0

添加静态将无法正常工作,问题是脚本不工作期间 – yezzz

+0

您可以尝试禁用autoptimize插件并查看是否有帮助。如果$(document).ready(function(){...}) 被称为 – Vahan