+ 1

How To Link A .js File To HTML file.

I'm using Brackets, and I tried using inline JS and it didn't work, so I migrated the script to a new document because the HTML file was getting cluttered anyway. How do I link it?

8th Jul 2017, 2:06 AM
Spoops
Spoops - avatar
4 Respuestas
+ 3
<script src='myjs.js'></script>
8th Jul 2017, 2:09 AM
Andrés04_ve
Andrés04_ve - avatar
+ 4
<script src="script.js"></script> Using native JS, but if you wanna include a file using JQuery you can try: jQuery.getScript() function Usage: $(selector).getScript(url,success(response,status)) Example: $("button").click(function(){ $.getScript("demo_ajax_script.js"); });
8th Jul 2017, 2:17 AM
Oussama Bezzad
Oussama Bezzad - avatar
0
Does that work with jQuery as well?
8th Jul 2017, 2:10 AM
Spoops
Spoops - avatar
0
I'm not sure, I don't know jQuery. Probably you can do: <script src=jquery></script> <script src="myjs.js"></script>
8th Jul 2017, 2:18 AM
Andrés04_ve
Andrés04_ve - avatar