SlideShare a Scribd company logo
EVENTS AND
EVENT HANDLERS
JAVASRIPT
JAVASCRIPT EVENTS
• HTML events are "things" that happen to HTML elements.
• When JavaScript is used in HTML pages, JavaScript can "react" on these
events.
HTML EVENTS
• An HTML event can be something the browser does, or something a user does.
• Here are some examples of HTML events:
• An HTML web page has finished loading
• An HTML input field was changed
• An HTML button was clicked
• Often, when events happen, you may want to do something.
• JavaScript lets you execute code when events are detected.
• HTML allows event handler attributes, with JavaScript code, to be added to
HTML elements.
HTML EVENTS SYNTAX
• With single quotes:
<some-HTML-element some-event='some JavaScript'>
• With double quotes:
<some-HTML-element some-event="some JavaScript">
• Example
• In the following example, an onclickattribute (with code), is added
to a button element:
<button onclick="document.getElementById('demo').innerHTML = Date()">The
time is?</button>
ONCLICK EVENT
<!DOCTYPE html>
<html>
<body>
<button onclick="document.getElementById('demo').innerHTML=Date()">The time
is?</button>
<p id="demo"></p>
</body>
</html>
COMMON HTML EVENTS
Event Description
onchange An HTML element has been changed
onclick The user clicks an HTML element
onmouseover The user moves the mouse over an HTML element
onmouseout The user moves the mouse away from an HTML element
onkeydown The user pushes a keyboard key
onload The browser has finished loading the page
WHAT CAN JAVASCRIPT DO?
• Event handlers can be used to handle, and verify, user input, user actions,
and browser actions:
• Things that should be done every time a page loads
• Things that should be done when the page is closed
• Action that should be performed when a user clicks a button
• Content that should be verified when a user inputs data
• And more ...

More Related Content

What's hot (14)

PPT
ASP.NET Session 9
Sisir Ghosh
 
PPTX
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
PDF
Killer Salesforce Admin Activity Hacks
RingLead
 
PDF
JavaScript framework overview
JetRuby Agency
 
PPT
Web Os Hands On
360|Conferences
 
PDF
4 pages 4 k
mohammedchemsi
 
PDF
Autopilot
coseng zuiken
 
DOC
Autopilotnew money money $$
KamilBejm1
 
DOCX
Right one
Chris Jones
 
ODP
Wellrailed - Cucumber tips
breccan
 
PDF
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
Fatima1567
 
PPTX
DHTML - Events & Buttons
Deep Patel
 
PDF
The Lego Data Layer
Carmen Mardiros
 
PDF
Autopilot method $
RyanRoberts127
 
ASP.NET Session 9
Sisir Ghosh
 
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
 
Killer Salesforce Admin Activity Hacks
RingLead
 
JavaScript framework overview
JetRuby Agency
 
Web Os Hands On
360|Conferences
 
4 pages 4 k
mohammedchemsi
 
Autopilot
coseng zuiken
 
Autopilotnew money money $$
KamilBejm1
 
Right one
Chris Jones
 
Wellrailed - Cucumber tips
breccan
 
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
Fatima1567
 
DHTML - Events & Buttons
Deep Patel
 
The Lego Data Layer
Carmen Mardiros
 
Autopilot method $
RyanRoberts127
 

Similar to FYBSC IT Web Programming Unit III Events and Event Handlers (20)

PPTX
Html events with javascript
YounusS2
 
PPTX
Event In JavaScript
ShahDhruv21
 
PPTX
JavaScript_Event_Handling_Presentation.pptx
Captain81145
 
PPTX
JavaScript_Event_Handling_Updated_______
Captain81145
 
PPTX
types of events in JS
chauhankapil
 
PPTX
5 .java script events
chauhankapil
 
PDF
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
PPTX
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
NetajiGandi1
 
PPT
Document_Object_Model_in_javaScript..................................ppt
rahamatmandal2005
 
PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPTX
Learn Javascript Basics
Khushiar
 
PPTX
Javascript 2
pavishkumarsingh
 
PPTX
Dom(document object model)
Partnered Health
 
PPTX
DOM_and_JS_Events_Presentation_simpleandShort.pptx
shivaninegi0435
 
PPTX
Unit ii java script and xhtml documents and dynamic documents with javascript
zahid7578
 
PPTX
Client Web
Markiyan Matsekh
 
PPTX
High performance websites session1
amr elgarhy
 
PDF
Javascript talk1
Pratik Kunpara
 
PDF
Html,javascript & css
Predhin Sapru
 
PPTX
13. session 13 introduction to dhtml
Phúc Đỗ
 
Html events with javascript
YounusS2
 
Event In JavaScript
ShahDhruv21
 
JavaScript_Event_Handling_Presentation.pptx
Captain81145
 
JavaScript_Event_Handling_Updated_______
Captain81145
 
types of events in JS
chauhankapil
 
5 .java script events
chauhankapil
 
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
NetajiGandi1
 
Document_Object_Model_in_javaScript..................................ppt
rahamatmandal2005
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Learn Javascript Basics
Khushiar
 
Javascript 2
pavishkumarsingh
 
Dom(document object model)
Partnered Health
 
DOM_and_JS_Events_Presentation_simpleandShort.pptx
shivaninegi0435
 
Unit ii java script and xhtml documents and dynamic documents with javascript
zahid7578
 
Client Web
Markiyan Matsekh
 
High performance websites session1
amr elgarhy
 
Javascript talk1
Pratik Kunpara
 
Html,javascript & css
Predhin Sapru
 
13. session 13 introduction to dhtml
Phúc Đỗ
 
Ad

More from Arti Parab Academics (20)

PPTX
COMPUTER APPLICATIONS Module 4.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 1 HPSY - Copy.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 5.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 1 CAH.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 3.pptx
Arti Parab Academics
 
PPTX
COMPUTER APPLICATIONS Module 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 4-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 5-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 3-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 2.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 1-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 3.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 2-Chapter 1.pptx
Arti Parab Academics
 
PPTX
Health Informatics- Module 1-Chapter 2.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 4.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 1 HPSY - Copy.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 5.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 1 CAH.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 3.pptx
Arti Parab Academics
 
COMPUTER APPLICATIONS Module 2.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 4-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 5-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 3-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 2.pptx
Arti Parab Academics
 
Health Informatics- Module 1-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 3.pptx
Arti Parab Academics
 
Health Informatics- Module 2-Chapter 1.pptx
Arti Parab Academics
 
Health Informatics- Module 1-Chapter 2.pptx
Arti Parab Academics
 
Ad

Recently uploaded (20)

PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Horarios de distribución de agua en julio
pegazohn1978
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 

FYBSC IT Web Programming Unit III Events and Event Handlers

  • 2. JAVASCRIPT EVENTS • HTML events are "things" that happen to HTML elements. • When JavaScript is used in HTML pages, JavaScript can "react" on these events.
  • 3. HTML EVENTS • An HTML event can be something the browser does, or something a user does. • Here are some examples of HTML events: • An HTML web page has finished loading • An HTML input field was changed • An HTML button was clicked • Often, when events happen, you may want to do something. • JavaScript lets you execute code when events are detected. • HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.
  • 4. HTML EVENTS SYNTAX • With single quotes: <some-HTML-element some-event='some JavaScript'> • With double quotes: <some-HTML-element some-event="some JavaScript"> • Example • In the following example, an onclickattribute (with code), is added to a button element: <button onclick="document.getElementById('demo').innerHTML = Date()">The time is?</button>
  • 5. ONCLICK EVENT <!DOCTYPE html> <html> <body> <button onclick="document.getElementById('demo').innerHTML=Date()">The time is?</button> <p id="demo"></p> </body> </html>
  • 6. COMMON HTML EVENTS Event Description onchange An HTML element has been changed onclick The user clicks an HTML element onmouseover The user moves the mouse over an HTML element onmouseout The user moves the mouse away from an HTML element onkeydown The user pushes a keyboard key onload The browser has finished loading the page
  • 7. WHAT CAN JAVASCRIPT DO? • Event handlers can be used to handle, and verify, user input, user actions, and browser actions: • Things that should be done every time a page loads • Things that should be done when the page is closed • Action that should be performed when a user clicks a button • Content that should be verified when a user inputs data • And more ...