Today with the help of this article I am going to explain you to override predefined functions and predefined events on a selector without changing in the core file.
Override Event
Below code snippet show that with the help of .off() function we can override events in jquery
$(document).off('event', 'selector').on('event', 'selector', function() { // Your code });
override function
Suppose you have a predefined js function helloWorld
function helloWorld (argument) { alert(argument); }
Now, if you want to override this function then
var origHelloWorld = window.helloWorld; window.helloWorld = function(argument) { //your code origHelloWorld(argument); // after your code if you want to call original function }
That’s all in this article, hope it will help you to override functions and events in js. Try this and if you have any query then just comment below. 🙂
Be the first to comment.