jquery - HTML Scroll position when anchor clicked -
I have access to an MVC app and JQuery.
I have an anchor that I set it up
& lt; A href = "#" id = "addcomment" & gt; Add comment & lt; / A & gt; Then when an anchor is clicked, I do this
$ ('# addcomment'). Click (function () {$ ('# divComments') .Sliddown (2000);}); The problem occurs when anchor clicks on the browser scrolls above the window, the quick link is clicked and then the div scrolls
How do I stop it?
Malcolm
You have to add return false; To prevent the default link event action from occurring, the default link in this case below your click function will be going to the top of the event page because the browser to go to the top of # If it tells you, it will look like this:
$ ('# addcomment'). Click (function () {$ ('# divComments'). SlideDown (2000); Returned;}); Although it is also acceptable:
$ ('# addcomment'). Click (function (e) {$ ('# divComments') SlideDown (2000); E.Pravant Default ();}); .
Comments
Post a Comment