Post about javascript , es6 via definitional approach.

Joined December 2021
2 Photos and videos
1/n: Lets talk about Events in Javascript. HTML DOM events ( like 𝐜𝐥𝐢𝐜𝐤 on button,𝐜𝐡𝐚𝐧𝐠𝐞 dropdown,𝐟𝐨𝐜𝐮𝐬 on input text,𝐝𝐛𝐥𝐜𝐥𝐢𝐜𝐤 : double click on element ) allow JavaScript to register different event handlers on elements in an HTML document. #javascript
1
3/n: Here we are adding an event listener to the paragraph element (paraElement). This is a method that takes two input values (called arguments) , the type of event we are listening out for (in this case click) as a string, and the code we want to run when the event occurs.
1
4/n: Here 𝐞𝐯𝐞𝐧𝐭 𝐡𝐚𝐧𝐝𝐥𝐞𝐫 is clickElement( ) function. Note : Inside addEventListener clickElement function is written without parenthesis is because we do not want to invoke as the page loads. This will only invoke when user click on that element.
1/n : How do you add JavaScript to your page? 1. Internal JavaScript : In your HTML file you can add <script> /* Javascript code goes here */ </script> tag just before your closing </head> tag or at the end of the <body> tag. Let's discuss about putting JS in <head> tag
1
1
3/n : In this method JavaScript is loaded and run in the head of the document, before the HTML body is parsed. This could cause an error, so we've used some constructs to get around it.
1
1
4/n: This is an event listener, which listens for the browser's DOMContentLoaded event, which signifies that the HTML body is completely loaded and parsed. The JavaScript inside this block will not run until after that event is fired, therefore the error is avoided.
1