Embed presentation
Downloaded 92 times











![12Focus & Blur Event Example:<!DOCTYPE html><html><head><title>Demo</title></head><body><h1>Hello How Are You...?</h1><form>Click This Button<br/><input type="button" value="Click Me!" onclick="myFun()"/><br/><input type="text" id="username" onfocus="this.blur()"/><br/></form><script type="text/javascript">function myFun(){document.getElementById("username").value="Dhruv";}</script></body></html>[fig.1 Before Click On That Button][fig.2 After Click On That Button]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-12-2048.jpg&f=jpg&w=240)

![14Syntaxtarget.addEventListener(type, listener[, options]);target.addEventListener(type, listener[, useCapture]);target.addEventListener(type, listener[, useCapture, wantsUntrusted ]);document.getElementById("myBtn").addEventListener("click", displayDate);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-14-2048.jpg&f=jpg&w=240)

![16Syntaxtarget.removeEventListener(type, listener[, options]);target.removeEventListener(type, listener[, useCapture]);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-16-2048.jpg&f=jpg&w=240)

![18Output[fig.3 Initial Page] [fig.4 When Click On Change Or Display][fig.5 When Click On Hide] [fig.6 When Click On Color Change]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-18-2048.jpg&f=jpg&w=240)


This document discusses JavaScript events and event listeners. It begins with an introduction that defines events as notifications that specific actions occurred, like user or browser actions. Event handlers are scripts that are executed in response to events. Events can be used to trigger JavaScript code that responds to user interactions. The document then provides examples of common event types like onclick, onsubmit, onmouseover, onmouseout, focus, and blur. It also discusses how to add and remove event listeners using addEventListener() and removeEventListener() methods. The document concludes with an example demonstrating how events can be used to change an HTML element in response to user clicks.











![12Focus & Blur Event Example:<!DOCTYPE html><html><head><title>Demo</title></head><body><h1>Hello How Are You...?</h1><form>Click This Button<br/><input type="button" value="Click Me!" onclick="myFun()"/><br/><input type="text" id="username" onfocus="this.blur()"/><br/></form><script type="text/javascript">function myFun(){document.getElementById("username").value="Dhruv";}</script></body></html>[fig.1 Before Click On That Button][fig.2 After Click On That Button]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-12-2048.jpg&f=jpg&w=240)

![14Syntaxtarget.addEventListener(type, listener[, options]);target.addEventListener(type, listener[, useCapture]);target.addEventListener(type, listener[, useCapture, wantsUntrusted ]);document.getElementById("myBtn").addEventListener("click", displayDate);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-14-2048.jpg&f=jpg&w=240)

![16Syntaxtarget.removeEventListener(type, listener[, options]);target.removeEventListener(type, listener[, useCapture]);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-16-2048.jpg&f=jpg&w=240)

![18Output[fig.3 Initial Page] [fig.4 When Click On Change Or Display][fig.5 When Click On Hide] [fig.6 When Click On Color Change]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fjseventwtppt-190418174721%2f75%2fEvent-In-JavaScript-18-2048.jpg&f=jpg&w=240)
