Uncaught ReferenceError: $ is not defined at funcoes.js: 2 [duplicate]

0
$('nav a').click(function(){
    e.preventDefault();
    var id = $(this).attr('href'),
        targetOffaset = $(id).offset().top,
        menuHeight = $('nav').innerHeight();

    $('html, body').animate({
        scrollTop: targetOffaset -59
    }, 500);
});
    
asked by anonymous 14.02.2018 / 02:37

1 answer

0

This is because the dollar sign ( $ ) is an alias (or shortcut) for jQuery. That's why you need to add jQuery before calling funcoes.js . Ex:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><scriptsrc="funcoes.js"></script>
    
14.02.2018 / 02:51