I have 2 events
First:
$(window).on("scroll", function() {
if (($(this).scrollTop()+h) >= $(".services-procent-ul").offset().top){
circle();
$(window).off("scroll");
}
});
Second:
$(window).on("scroll", function() {
if($(window).scrollTop() > 0){
$('.nav2').fadeIn('slow');
$('.nav1').fadeOut('fast');
}else{
$('.nav2').fadeOut('fast');
$('.nav1').fadeIn('slow');
}
});
The first event I need to disable after its execution. But I need to work a second event.
You can add event namespace to first event and disable it then by namespace wherever you want:
$(window).on("scroll.once", function() {
...
$(window).off("scroll.once");
If you want to "disable" an event after its execution You could use Jquery .one()
The .one() method is identical to .on(), except that the handler is unbound after its first invocation
$(window).one("scroll", function() {
//doSomething
});
If you are looking for a way to disable certain event callback after certain condition and not disable all of them You can add Event Namespace as @antyrat answered
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With