javascript - Why is this JQuery error happening? Animate is not a function -


i learning jquery , trying work way around scroll effect. anyway, trying make code work having trouble in doing so. breaks when runs animate function:

i appreciate on one. thank you.

uncaught typeerror: $(...).animate not function
@ htmlanchorelement. (script.js:58)
@ htmldocument.dispatch (jquery-3.1.1.slim.min.js:3)
@ htmldocument.q.handle (jquery-3.1.1.slim.min.js:3)

// select anchor tags click on   $(document).on("click", "a", function(event) {    console.log("item clicked");      // clear out default action      event.preventdefault();    console.log("working until now");      // animate selected selected target    $("html,body").animate({      scroll: $($(this).attr('href')).offset().top    }, 900);    console.log("no errors now");  });
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-a7fzj7v+d/sdmmqp/noqwlilvusjfdhw+k9omg/a/eheadgtzns3hpfag6ed950n" crossorigin="anonymous"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-dztdapbwprxsa/3eyeeuwrwcy7g5kfbe8ffjk5jaixuyhkkdx6qin1dkwx51bbrb" crossorigin="anonymous"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vbwwzlzj8ea9acx4pew3rvhjgjt7zpknpzk+02d9phzyevke+jo0iegizqplforn" crossorigin="anonymous"></script>  <script src="javascript/script.js">  </script>

it's because of jquery version use. https://code.jquery.com/jquery-3.1.1.slim.min.js

slim version of jquery not contain original jquery functions.

you should use full version. can download here.

it better understand if read article here @ point in find statement , quote:

slim build

finally, we’ve added new release. don’t need ajax, or prefer use 1 of many standalone libraries focus on ajax requests. , simpler use combination of css , class manipulation web animations. along regular version of jquery includes ajax , effects modules, we’re releasing “slim” version excludes these modules. in all, excludes ajax, effects, , deprecated code.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -