Search code examples
javascriptjqueryjquery-3

this code wont run on jquery-3.1.0.js


Is there any reason why this code wont run on JS 3.1.0 running locally ( downloaded from http://jquery.com/download/ ) but runs fine when I load it from http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js

<script>
$(window).load(function() {
$(".se-pre-con").fadeOut("slow");;
});
</script>

I'm confuse... please help...


Solution

  • The jQuery that you're using here http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js uses jQuery 1.6.1, while the jQuery that you've downloaded from https://jquery.com/download/ uses jQuery 3.

    And in the documentation of jQuery 3 here, it says:

    Breaking change: .load(), .unload(), and .error() removed

    So instead of using .load() you can just use $(function() {}); like this:

    $(function() {
      // insert code here...
    });