javascript - How to enable default link button after preventDefault() -
i want scroll top when user press login button. using link button login. here logic scroll top.
<asp:linkbutton id="cmdlogin" resourcekey="cmdlogin" cssclass="dnnprimaryaction" text="login" runat="server" /> <script type="text/javascript"> jquery(function($) { var actionlinks = $("a[id$=cmdlogin]"); actionlinks.click(function(e) { e.preventdefault(); // e.stoppropagation(); $('html,body').animate({ scrolltop: 0 }, 'fast'); }); }); </script>
the scrolling working fine code problem when click on login button got disable. can click again prevent default css code , button seems disable. not showing error message because of preventdefault(). please me how can enable default after using event.preventdefault();
thanks.
replace .click(
.one( "click",
jquery(function($) { var actionlinks = $("a[id$=cmdlogin]"); actionlinks.one( "click", function(e) { e.preventdefault(); // e.stoppropagation(); $('html,body').animate({ scrolltop: 0 }, 'fast'); }); });
- the first time button pressed event handler run
- the second time button pressed, default handler run
Comments
Post a Comment