Menu Close
    Hire Us Request Quote Reading List Switch to Dark Mode

    How to override JavaScript/jQuery functions and events?

    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. 🙂

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close

    Table of Content

    Hide Index