- Create a js file and add in your HTML file using src tag
<html> <head> <title>Title Goes Here</title> </head> <body> <script> document.write("here is some text"); </script> </body> </html>
<script> // Your code goes here... </script>
You can also use onclick event handler too. This is known as onclick event handler.
I hope this post is helpful to you. Feel free to comment in the below comment section.