0

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 Answers1

0

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.

abc123
  • 17,855
  • 7
  • 52
  • 82
  • Hi thanks for quick reply. but i want to mention one thing that i am using this code through some kind AB tesing tool. – DesignerAshish Sep 19 '17 at 19:58
  • @DesignerAshish okay? can you explain what you are trying to add as a requirement? like no jquery? – abc123 Sep 20 '17 at 05:19