Клик на "аккордеон" на внутренней срабатывает как ссылка (без раскрытия)
Доброго времени суток, форумчане!
Идет разработка сайта, в шапке у которого меню-аккордеон. Если кликнуть по нему на главной странице - все Ок, меню раскрывается и ведет себя, как задумано. А вот клик на аккордеон на внутренней странице срабатывает как гиперссылка и перебрасывает по адресу www.новыйсайт.ru/# Вот код главной страницы: <div class="top-nav"> <div class="nav-icon"> <a href="#" class="right_bt" id="activator"> <span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span> </a> <a class="scroll best-works" href="#best-works">ЛУЧШИЕ РАБОТЫ</a> <div class="clearfix"></div> </div> <div class="box" id="box"> <div class="box_content"> <div class="box_content_center"> <div class="form_content"> <div class="menu_box_list"> <ul> <li><a class="active" href="index.html"><span>Начать</span></a></li> <li class="full"><a href="#"><span>О компании</span></a> <ul> <li><a href="#">новости</a></li> <li><a href="#">лучшие работы</a></li> <li><a href="#">как мы работаем</a></li> <li><a href="#">библиотека</a></li> </ul> </li> </ul> </div> <a class="boxclose" id="boxclose"> <span> </span></a> </div> </div> </div> </div> </div> <script type="text/javascript"> var $ = jQuery.noConflict(); $(function() { $('#activator').click(function(){ $('#box').animate({'top':'0px'},900); $('#box').css({'height': $('#box').height(),'width': $('#box').width()}).addClass('fixed'); }); $('#boxclose').click(function(){ $('#box').removeClass('fixed'); $('#box').animate({'top':'-1000px'},900); }); }); $(document).ready(function(){ //Hide (Collapse) the toggle containers on load $(".toggle_container").hide(); //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) $(".trigger").click(function(){ $(this).toggleClass("active").next().slideToggle("slow"); return false; //Prevent the browser jump to the link anchor }); }); </script> ========================= А вот - с внутренней: <div class="top-nav"> <div class="nav-icon"> <a href="#" class="right_bt" id="activator"> <span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span> </a> <div class="clearfix"></div> </div> <div class="box" id="box"> <div class="box_content"> <div class="box_content_center"> <div class="form_content"> <div class="menu_box_list"> <ul> <li><a href="index.html"><span>Начать</span></a></li> <li class="full"><a href="#"><span>О компании</span></a> <ul> <li><a href="#">новости</a></li> <li><a href="#">лучшие работы</a></li> <li><a href="#">как мы работаем</a></li> <li><a href="#">библиотека</a></li> </ul> </li> </ul> </div> <a class="boxclose" id="boxclose"> <span> </span></a> </div> </div> </div> </div> </div> <script type="text/javascript"> var $ = jQuery.noConflict(); $(function() { $('#activator').click(function(){ $('#box').animate({'top':'0px'},900); $('#box').css({'height': $('#box').height(),'width': $('#box').width()}).addClass('fixed'); }); $('#boxclose').click(function(){ $('#box').removeClass('fixed'); $('#box').animate({'top':'-1000px'},900); }); }); $(document).ready(function(){ //Hide (Collapse) the toggle containers on load $(".toggle_container").hide(); //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) $(".trigger").click(function(){ $(this).toggleClass("active").next().slideToggle("slow"); return false; //Prevent the browser jump to the link anchor }); }); </script> Визуально все Ок. Пробовал в html и js частях менять анализируемый объект $('#activator').click(function(){ в зависимости от id страницы (например, $('#activator2').click(function(){) - но тоже не помогло. В чем затык? Подскажите, плз! :help: |
LouDminsk,
click(function(event){ event.preventDefault(); |
Цитата:
Только не совсем понял, в какое место кода нужно добавить указанный фрагмент? Можно немного подробнее? |
LouDminsk,
во все клики, добавить красное |
рони,
спасибо! Вопрос закрыт |
Часовой пояс GMT +3, время: 14:06. |