I mean when click on one
or two
that only first time scroll that id? In second click do nothing?
Thanks.
I mean when click on one
or two
that only first time scroll that id? In second click do nothing?
Thanks.
Just use a function called โoff.โ Please see below.
$("a[href^='#']").click(function scroll(e) {
e.preventDefault();
var position = $($(this).attr("href")).offset().top;
$("body, html").animate({
scrollTop: position
} /* speed */ );
$(this).off('click')
});
Thanks for answer!
I try it http://jsfiddle.net/L2yqw4ha/ but not seems work I mean when click on it agan and again do the event.
Is it fine now still my question how can do that like above vanilla JS example to do nothing about click? I mean when click on it do nothing? Because is not do animate but still does to jump to id.
Thanks!
There
$("a[href^='#']").click(function(e) {
e.preventDefault();
var position = $($(this).attr("href")).offset().top;
$("body, html").animate({
scrollTop: position
} /* speed */ );
$(this).off('click');
$(this).click(function(e) {e.preventDefault()} )
});
Yes you are right only one time and yes is about .one function
. Thank you!
I thought I had clicked save. Try this one.
Why do you think it is better than your use of the one
method?
Ahah now whitch the best one to accept ?