jquery - Link causing top of page jump -
update: i've found js file interfering. many replies.
i'm using code below toggle accordion menu, though each time .menu li.sub
clicked, page jumps top... i've tried placing return false
on place, can't seem work..
here's code; many thanks:
jquery(document).ready(function ($) { jquery('.menu ul').slideup(0); jquery('.menu li.sub').click(function () { var target = jquery(this).children('a'); if(target.hasclass('menu-expanded')){ target.removeclass('menu-expanded'); }else{ jquery('.menu-item > a').removeclass('menu-expanded'); target.addclass('menu-expanded'); } jquery(this).find('ul:first') .slidetoggle(350) .end() .siblings('li') .find('ul') .slideup(350); }); });
use return false @ end of click event handler:
jquery('.menu li.sub').click(function () { var target = jquery(this).children('a'); if(target.hasclass('menu-expanded')){ target.removeclass('menu-expanded'); }else{ jquery('.menu-item > a').removeclass('menu-expanded'); target.addclass('menu-expanded'); } jquery(this).find('ul:first') .slidetoggle(350) .end() .siblings('li') .find('ul') .slideup(350); return false; });
Comments
Post a Comment