codegurukool.com · Free coding tutorials & online compiler

Home › HTML Tutorial › JavaScript in HTML

JavaScript in HTML

Add behavior with script.

Put code in a script element, or load a file with src. Scripts at the end of the body run after the page has loaded.

Example code

<p id='x'>Before</p>
<script>document.getElementById('x').textContent='After';</script>'

Run this code in the online editor

← HTML iframesFile paths →