Events – JavaScript Basics

Things that happen to HTML elements are HTML Events and JS can react on these events when JS is used in HTML pages.
HTML event can be something that the user does. Some of the HTML events are :- an HTML button was clicked, HTML web page has finished loading. You might want to do something when event happens and JS lets to execute code when events are identified.
HTML grants event handler attributes, with JS Code, to be added to HTML elements.

WITH SINGLE QUOTATION :

<element event='code projects'>
WITH DOUBLE QUOTATION :

<element event="code projects">

Ex.

<!DOCTYPE html>
<html>
<body>
<p>Click Here To Display The Date.</p>
<button onclick="display()">The time is. .</button>

<script>
function display() {
 document.getElementById("ex").innerHTML = Date();
}
</script>

<p id="ex"></p>
</body>
</html>

Output :

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x