How can I access DOM objects in an external JS file?
I'm using an external JS 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 js file is loaded
externally. However everything works when I place it inside the html
document itself. How can give dom access to my js?
No comments:
Post a Comment