Search code examples
javascriptjqueryhashchange

$.on is not a function


I am getting following error when trying to run my website,

Uncaught TypeError: $(...).on is not a function

I am not well aware of javascript, hence i dont know what all this code does :

$(window).on('hashchange', function(){

var url = window.location.hash.replace("#/", "");

if(url != ""){

    setHashChange(true);

} else {

    iniMenuSlide("home");

}

});

Please guide me on how to resolve this error.


Solution

  • Paste below line in your page's head tag, preferably before any javascript linking or code.

    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    

    The error is coming because you are not linking jQuery file or linking to older version, which is not supporting on function.