SOLVED: I am the biggest dumb. I was so focused on where I intended to load my scripts (at the end of the body tag) that I wasn't paying attention to the head anymore.
Lo and behold I was loading my main.js twice, once in the head and once after jQuery loaded.
Thank you to everyone who tried to help, but ya can't cure my tunnel vision :/
ORIGINAL POST:
I am importing jQuery from Google's CDN, and I am loading it before my own js script, but on line 1 I'm getting a "$ is undefined" error with my $(document).ready()
function.
This error occurs whether I use $ or jQuery as the prefix.
I've been searching through forums for the past hour and all the solutions that people seem to have is to ensure that jQuery is loading before my other scripts and that it's not being interfered with by other libraries that might be using $, but I'm not using any other libraries, and I've taken the path straight from Google's site
I've also tried using Microsoft's CDN and jQuery's CDN.
I've checked in Chrome, Firefox, and Edge, all the same.
The network tab in dev tools shows jQuery loading first.
<body>
<aside>
<div id="nav">
<h2>ABOUT US</h2>
<h2 id="donate-button">DONATE NOW</h2>
<h2>CONTACT US</h2>
<h2>PHOTO GALLERY</h2>
</div>
</aside>
<!--SCRIPTS-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="Resources/JS/main.js"></script>
</body>
// Resources/JS/main.js
$(document).ready(function() {
console.log("READY");
$("#nav h2").css("background-color", "red")
});
All I'm trying to do is get this error to go away so I can actually start writing my script :/
I'm fairly new to JS and jQuery in particular, and I feel like the solution is so simple and I'm just looking in the wrong spots. But I've done a decent amount of searching and I can't find anyone who's solution works for me too.
EDIT:
Here are some screenshots from Chrome Dev Tools that were requested: