Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$ or jQuery is undefined

<script href="http://code.jquery.com/jquery-1.10.2.min.js"></script>

<script>
    console.log($);
    console.log(jQuery);
</script>

I get a message that $ or jQuery is undefined: what’s wrong?

It’s just an empty index.html, with no other code.

like image 749
yeah its me Avatar asked Nov 27 '22 11:11

yeah its me


2 Answers

You used the href attribute to include the script to the file.

href is an invalid attribute for <script></script> tags. Use src instead...

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
like image 192
War10ck Avatar answered Dec 09 '22 19:12

War10ck


You have an error in your declaration. You should use

<script src="...">

instead of

<script href="">.
like image 23
alphabit Avatar answered Dec 09 '22 17:12

alphabit