-3

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.

Gaurav Gandhi
  • 2,536
  • 2
  • 23
  • 35
Igor Martins
  • 1,859
  • 5
  • 28
  • 52

2 Answers2

2

The on method was introduced in jQuery 1.7 (which is pretty ancient these days). Since you don't seem to have it, you need to upgrade to a more recent version of jQuery.

The code calls one of two different functions depending on if the URL has changed to one with fragment identifier at the end or not.

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205
2

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.

Gaurav Gandhi
  • 2,536
  • 2
  • 23
  • 35