I'm using an external JavaScript file to access DOM objects with in my documents. The problem is that jQuery doesn't seem to have access if it's an externally loaded file. My code looks like:
<html>
<head>
</head>
<body>
<div id="domToChange" someAttribute="hi"></div>
<script src="officialJqueryLibrary"></script>
<script src="myJS.js"></script>
</body>
</html>
///////// myJS.js file
// Returns undefined
$('#domToChange').attr('someAttribute');
The DOM selector doesn't seem to find my div when the JavaScript file is loaded externally. However everything works when I place it inside the HTML document itself. How can I give DOM access to my JavaScript file?