There are three basic requirements to become a front-end developer:
What is a script tag?
This is a script tag with an src attribute in which we can provide a file name we want to reference.
Let’s look at an example:
We referenced the “code.js” file using the src attribute of <script> tag.
Now the code.js file:
alert("You Clicked me");
The result will be the same as the previous example i-e.
Id is unique and used for only one element.
<button id="btn">Click Me</button>
alert("You clicked me");
In this example we accessed the button element using getElementById(). After that we put an event that whenever a user clicks on the button an alert should be shown.
We can achieve the same output if we use:
It should be kept in mind that we have to set the class attribute in the button element.