codegurukool.com · Free coding tutorials & online compiler

Home › JavaScript Tutorial › JS where to

JS where to

Inline, in the head, or from a file.

Put code in a script element or load a file with src. Add defer to run after the page is parsed. Event attributes like onclick also hold code.

Example code

<button onclick='o.textContent='Clicked''>Attribute</button>
<p id='o'></p>
<!-- <script src='app.js' defer></script> -->

Run this code in the online editor

← JS introductionJS output →