SlideShare a Scribd company logo
1 of 10
JavaScript Events
Dr.A.Srinagesh
Event?
• User actions cause events.
• An event is some notable action occurring inside
the browser to which a script can respond.
• A JavaScript can be executed when an event
occurs, like when a user clicks on an HTML
element.
• Events are a part of the Document Object Model
(DOM) and every HTML element contains a set of
events which can trigger JavaScript Code.
Types of Events
• <body> and <frameset> Level Events
Attribute Value Description
onload script Script runs when a HTML document loads
onunload script Script runs when a HTML document
unloads
<form> Level Events
Attribute Value Description
onchange script Script runs when the element changes
onsubmit script Script runs when the form is submitted
onreset script Script runs when the form is reset
onselect script Script runs when the element is
selected
onblur script Script runs when the element loses
focus
onfocus script Script runs when the element gets
focus
Keyboard Events
Attribute Value Description
onkeydown script Script runs when key is
pressed
onkeypress script Script runs when key is
pressed and released
onkeyup script Script runs when key is
released
Mouse Events
Attribute Value Description
onclick script Script runs when a mouse click
ondblclick script Script runs when a mouse double-click
onmousedown script Script runs when mouse button is pressed
onmousemove script Script runs when mouse pointer moves
onmouseout script Script runs when mouse pointer moves
out of an element
onmouseover script Script runs when mouse pointer moves
over an element
onmouseup script Script runs when mouse button is
released
Event Bubbling
• When an event happens on an element, it first runs
the handlers on it, then on its parent, then all the way
up on other ancestors.
or
• Event bubbling directs an event to its intended target,
it works like this: A button is clicked and the event is
directed to the button.
• If an event handler is set for that object, the event is
triggered. If no event handler is set for that object,
the event bubbles up (like a bubble in water) to the
objects parent.
• The term event propagation is often used as a
synonym of event bubbling.
Event Bubbling
Why event bubbling?
• The concept of event bubbling was introduced
to deal with situations where a single event,
such as a mouse click, may be handled by two
or more event handlers defined at
different levels of the Document Object
Model (DOM) hierarchy.
Event Capture
Event capturing is the
opposite of bubbling (events
are handled at higher levels
first, then sink down to
individual elements at lower
levels).
Event capturing is supported
in fewer browsers and rarely
used.

More Related Content

Similar to JavaScript_Events.pptx

Asp.net event handler
Asp.net event handlerAsp.net event handler
Asp.net event handlerSireesh K
 
Dive into javascript event
Dive into javascript eventDive into javascript event
Dive into javascript eventGoddy Zhao
 
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9DanWooster1
 
【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript eventtbosstraining
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+featuresFaisal Aziz
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intentPERKYTORIALS
 
Chap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxChap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxTadeseBeyene
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handlingteach4uin
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFQuang Nguyễn Bá
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesEthan Cha
 
Introj Query Pt2
Introj Query Pt2Introj Query Pt2
Introj Query Pt2kshyju
 
5 .java script events
5 .java script   events5 .java script   events
5 .java script eventschauhankapil
 
types of events in JS
types of events in JS types of events in JS
types of events in JS chauhankapil
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxusvirat1805
 

Similar to JavaScript_Events.pptx (20)

Asp.net event handler
Asp.net event handlerAsp.net event handler
Asp.net event handler
 
Dive into javascript event
Dive into javascript eventDive into javascript event
Dive into javascript event
 
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
 
【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+features
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
Events.pdf
Events.pdfEvents.pdf
Events.pdf
 
Chap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxChap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptx
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handling
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPF
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And Types
 
Events1
Events1Events1
Events1
 
Introj Query Pt2
Introj Query Pt2Introj Query Pt2
Introj Query Pt2
 
5 .java script events
5 .java script   events5 .java script   events
5 .java script events
 
types of events in JS
types of events in JS types of events in JS
types of events in JS
 
Mobile Application Development class 005
Mobile Application Development class 005Mobile Application Development class 005
Mobile Application Development class 005
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 

Recently uploaded

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

JavaScript_Events.pptx

  • 2. Event? • User actions cause events. • An event is some notable action occurring inside the browser to which a script can respond. • A JavaScript can be executed when an event occurs, like when a user clicks on an HTML element. • Events are a part of the Document Object Model (DOM) and every HTML element contains a set of events which can trigger JavaScript Code.
  • 3. Types of Events • <body> and <frameset> Level Events Attribute Value Description onload script Script runs when a HTML document loads onunload script Script runs when a HTML document unloads
  • 4. <form> Level Events Attribute Value Description onchange script Script runs when the element changes onsubmit script Script runs when the form is submitted onreset script Script runs when the form is reset onselect script Script runs when the element is selected onblur script Script runs when the element loses focus onfocus script Script runs when the element gets focus
  • 5. Keyboard Events Attribute Value Description onkeydown script Script runs when key is pressed onkeypress script Script runs when key is pressed and released onkeyup script Script runs when key is released
  • 6. Mouse Events Attribute Value Description onclick script Script runs when a mouse click ondblclick script Script runs when a mouse double-click onmousedown script Script runs when mouse button is pressed onmousemove script Script runs when mouse pointer moves onmouseout script Script runs when mouse pointer moves out of an element onmouseover script Script runs when mouse pointer moves over an element onmouseup script Script runs when mouse button is released
  • 7. Event Bubbling • When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors. or • Event bubbling directs an event to its intended target, it works like this: A button is clicked and the event is directed to the button. • If an event handler is set for that object, the event is triggered. If no event handler is set for that object, the event bubbles up (like a bubble in water) to the objects parent. • The term event propagation is often used as a synonym of event bubbling.
  • 9. Why event bubbling? • The concept of event bubbling was introduced to deal with situations where a single event, such as a mouse click, may be handled by two or more event handlers defined at different levels of the Document Object Model (DOM) hierarchy.
  • 10. Event Capture Event capturing is the opposite of bubbling (events are handled at higher levels first, then sink down to individual elements at lower levels). Event capturing is supported in fewer browsers and rarely used.