JavaScript Basics
JavaScript is used to make your website interactive.
You can write JavaScript in two ways:
Option 1: Inside your HTML file using the <script> tag.
Option 2: In a separate file called "script.js" and link it in your HTML.
Example of JavaScript inside HTML:
<script>
alert("Welcome to Brack Study!");
</script>
Example of JavaScript in "script.js":
function greet() {
alert("Hello from external file!");
}
To run this function when a button is clicked:
<button onclick="greet()">Click Me</button>