I want override animate effect on html & body

84 Views Asked by At

Suppose below is my code. i am not responsible to make change directly to code. hence i am doing it via console. and i want to unbind this html & body animation but someotherFunction() should work as it is. there may be too many functions as well beyond my imagination like below and i want all to work as it is but only animate should be unbind.

$("#button").click(function() {
    $('html, body').animate({
        scrollTop: $("#myDiv").offset().top
    }, 2000);
   someOtherFunction();
   someMoreFunctionIDontKnowAbout();
});
1

There are 1 best solutions below

2
On

Answer

We will unbind the .click event then we will add the new binding.

$('#button').unbind("click");
$('#button').click(function() {
   someOtherFunction();
   someMoreFunctionIDontKnowAbout();
});


Side Note

I recommend if this is something you will be doing a lot and only want for yourself that you should install tampermonkey or a similar tool to run jquery/javascript of your own on a specific domain.