-2

Im working on a responsive website with side menu. And now when i click on menu item the menu collapse not going to the link (#home #About).I want both closing and opening,

<div id="sidr" class="sidr left" style="display: block; left: 0px;">
<a href="#sidr-close" class="dl-trigger icon-mobile-menu dfd-sidr-close">
    <span class="icon-wrap dfd-middle-line"></span>
    <span class="icon-wrap dfd-top-line"></span>
    <span class="icon-wrap dfd-bottom-line"></span>
</a>
<div class="sidr-inner"><ul class="sidr-dropdown-menu"><li class="mega-menu-item nav-item menu-item-depth-0"><a href="#home" class="menu-link main-menu-link item-title sub-nav" role="group" aria-expanded="false" aria-hidden="true">Home</a></li>

and

e(".sub-nav").unbind("click").bind("touchend click", function(t) {
        t.preventDefault(), e.sidr("close")
    })

I used the above code. Hope i will get a correct solution.

  • Can you provide us a working fiddle that demonstrates the problem? [jsfiddle.net](http://jsfiddle.net) – Emirhan Özlen Jun 22 '16 at 10:14
  • put your `html` code – Codeone Jun 22 '16 at 10:14
  • Please provide an example using a code snippet that runs with what you have so far, or try to explain your question better. – Randy Jun 22 '16 at 10:14
  • add html code also – Pawan Lakhara Jun 22 '16 at 10:15
  • 2
    @EmirhanÖzlen Don't try to make people use jsfiddle, they can perfectly well use [snippets on Stack Overflow](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/), instead of external resources. – Randy Jun 22 '16 at 10:15
  • @randy I don't like stackoverflow's snippets. – Emirhan Özlen Jun 22 '16 at 10:16
  • @EmirhanÖzlen Get used to it. If you use external resources, they may go down and the question/answer becomes useless. Snippets rule, and using JSFiddle might (im not saying should) result in downvotes unfortunately. – Randy Jun 22 '16 at 10:18
  • @randy They should improve it. I find it uncomfortable to work on. Meh anyways thanks for your suggestion. – Emirhan Özlen Jun 22 '16 at 10:20

1 Answers1

0

Remove the t.preventDefault() in your js and it will work:

e(".sub-nav").unbind("click").bind("touchend click", function(t) {
         e.sidr("close");
    })

the prevent default is preveting your go to link behaviour.

Arathi Sreekumar
  • 2,544
  • 1
  • 17
  • 28