0
Where to put script.js
i have an html document. i've put an external script inside the <script> tag within the head. i need to change some behaviour in the middle of the body tag inside a nested div which is nested inside another div, which is again nested inside another div, which is at the end nested in one more div. The question is - how to call upon a script and where to place it?
4 Respostas
0
Scripts are mostly called before the </body> tag to reduce the loading time i.e to add script just do this..
<script src="yourscript.js">
</script>
I hope you find what you need! :)
0
ok. when i put it like that it changes nothing.. when i put it inside a script tag and call upon it just beyond the div i wanna change it works - why?
0
The script tag should be placed at the end of the body so we won't waste our time by loading the script first. To modify your div-inside other div-inside another div you could add an id to that div. So when you call it in the script, you could use document.getElementById() .
0
Or maybe your external script is not in the same folder with the html file. So you will rather use :
<script src="folderName/yourScript.js"></script>