0
How to relate js and html?
Example: JS: var x=2 document.write(x) How to align it to the centre of page?
3 Respuestas
+ 2
You can attach js to html in two ways
1. Internal js
</body>
<script>
//js code here
</script>
</html>
2. External js
my a js file with extension js and write your js code in it.
to attach it to html you can use
<link src="myfile.js"> in head tag .
***
In sololearn js section is already attached to html so no need of that here.
+ 4
To link a Js file with your HTML, you only have to add the source of the script inside the body tag or outside; it doesn't matter. If you are working with libraries, like jQuery, you can add the URL of the library in the source.