SlideShare a Scribd company logo
JavaScript Event Handling
• Making Web Pages Interactive
• - Created using JavaScript
• - Responds to user actions
• - Makes pages dynamic
• - Your Name / Roll No / Date
Introduction to JavaScript
• - JavaScript is a scripting language
• - Adds behavior to web pages
• - Used for interactivity
• - Works with HTML & CSS
What is an Event?
• - An event is a user action
• - Examples: click, type, scroll
• - Events occur in browser
• - JavaScript can respond to them
What is Event Handling?
• - Code that responds to events
• - Can trigger functions
• - Written using JavaScript
• - Used to make pages interactive
Why Event Handling is Important
• - Makes pages dynamic
• - Responds to user inputs
• - Allows real-time interaction
• - Improves user experience
Inline Event Handling
• - Directly in HTML tag
• - Easy to use for small scripts
• - Uses attributes like onclick
• - Example:
• <button onclick="alert('Hello!')">Click
Me</button>
JavaScript Function Example
• - JavaScript functions respond to events
• - Called inside onclick or other attributes
• - Easy way to separate logic
• - Example:
• function sayHi() { alert('Hi!'); }
Common JavaScript Events
• - onclick: when user clicks
• - onmouseover: mouse over element
• - onkeydown: key press
• - onchange: input field changes
Mouse Events
• - onclick: click element
• - ondblclick: double click
• - onmouseover: mouse over element
• - onmouseout: mouse leaves element
Keyboard Events
• - onkeydown: key is pressed down
• - onkeyup: key is released
• - onkeypress: key is pressed and held
• - Useful in forms or games
The addEventListener() Method
• - Better than inline handlers
• - Can attach multiple events
• - More flexible and cleaner
• - Syntax: element.addEventListener('event',
function)
onclick vs. addEventListener()
• - onclick: simple and quick
• - addEventListener: more powerful
• - addEventListener allows multiple listeners
• - Better for large apps
Real-life Examples
• - Button click shows message
• - Typing triggers search
• - Hover changes background
• - Scrolling loads more content
Summary
• - JavaScript handles browser events
• - Events include click, type, hover, etc.
• - Can use inline or JS code
• - Makes web pages interactive
Questions / Thank You
• - Any questions?
• - Thanks for your attention!
• - JavaScript makes web fun!
• - Happy coding!

More Related Content

Similar to JavaScript_Event_Handling_Updated_______ (20)

PPTX
Event In JavaScript
ShahDhruv21
 
PPTX
Learn Javascript Basics
Khushiar
 
PPTX
Javascript 2
pavishkumarsingh
 
PDF
JavaScript
tutorialsruby
 
PDF
JavaScript
tutorialsruby
 
PPTX
FYBSC IT Web Programming Unit III Events and Event Handlers
Arti Parab Academics
 
PPTX
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
utsavsd11
 
PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPTX
Lesson 205 07 oct13-1500-ay
Codecademy Ren
 
PPT
Document_Object_Model_in_javaScript..................................ppt
rahamatmandal2005
 
PPT
Event Programming JavaScript
MuhammadRehan856177
 
PPT
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
PPT
javascript Event Handling and introduction to event.ppt
Lalith86
 
PPTX
Introduction to JavaScript DOM and User Input.pptx
GevitaChinnaiah
 
PPT
Learn javascript easy steps
prince Loffar
 
PDF
Introduction to web programming with JavaScript
T11 Sessions
 
PPTX
Dom(document object model)
Partnered Health
 
PPS
CS101- Introduction to Computing- Lecture 32
Bilal Ahmed
 
PPTX
Javascript note for engineering notes.pptx
engineeradda55
 
Event In JavaScript
ShahDhruv21
 
Learn Javascript Basics
Khushiar
 
Javascript 2
pavishkumarsingh
 
JavaScript
tutorialsruby
 
JavaScript
tutorialsruby
 
FYBSC IT Web Programming Unit III Events and Event Handlers
Arti Parab Academics
 
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
utsavsd11
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Lesson 205 07 oct13-1500-ay
Codecademy Ren
 
Document_Object_Model_in_javaScript..................................ppt
rahamatmandal2005
 
Event Programming JavaScript
MuhammadRehan856177
 
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
javascript Event Handling and introduction to event.ppt
Lalith86
 
Introduction to JavaScript DOM and User Input.pptx
GevitaChinnaiah
 
Learn javascript easy steps
prince Loffar
 
Introduction to web programming with JavaScript
T11 Sessions
 
Dom(document object model)
Partnered Health
 
CS101- Introduction to Computing- Lecture 32
Bilal Ahmed
 
Javascript note for engineering notes.pptx
engineeradda55
 

Recently uploaded (20)

PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Introduction presentation of the patentbutler tool
MIPLM
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
infertility, types,causes, impact, and management
Ritu480198
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
epi editorial commitee meeting presentation
MIPLM
 
Ad

JavaScript_Event_Handling_Updated_______

  • 1. JavaScript Event Handling • Making Web Pages Interactive • - Created using JavaScript • - Responds to user actions • - Makes pages dynamic • - Your Name / Roll No / Date
  • 2. Introduction to JavaScript • - JavaScript is a scripting language • - Adds behavior to web pages • - Used for interactivity • - Works with HTML & CSS
  • 3. What is an Event? • - An event is a user action • - Examples: click, type, scroll • - Events occur in browser • - JavaScript can respond to them
  • 4. What is Event Handling? • - Code that responds to events • - Can trigger functions • - Written using JavaScript • - Used to make pages interactive
  • 5. Why Event Handling is Important • - Makes pages dynamic • - Responds to user inputs • - Allows real-time interaction • - Improves user experience
  • 6. Inline Event Handling • - Directly in HTML tag • - Easy to use for small scripts • - Uses attributes like onclick • - Example: • <button onclick="alert('Hello!')">Click Me</button>
  • 7. JavaScript Function Example • - JavaScript functions respond to events • - Called inside onclick or other attributes • - Easy way to separate logic • - Example: • function sayHi() { alert('Hi!'); }
  • 8. Common JavaScript Events • - onclick: when user clicks • - onmouseover: mouse over element • - onkeydown: key press • - onchange: input field changes
  • 9. Mouse Events • - onclick: click element • - ondblclick: double click • - onmouseover: mouse over element • - onmouseout: mouse leaves element
  • 10. Keyboard Events • - onkeydown: key is pressed down • - onkeyup: key is released • - onkeypress: key is pressed and held • - Useful in forms or games
  • 11. The addEventListener() Method • - Better than inline handlers • - Can attach multiple events • - More flexible and cleaner • - Syntax: element.addEventListener('event', function)
  • 12. onclick vs. addEventListener() • - onclick: simple and quick • - addEventListener: more powerful • - addEventListener allows multiple listeners • - Better for large apps
  • 13. Real-life Examples • - Button click shows message • - Typing triggers search • - Hover changes background • - Scrolling loads more content
  • 14. Summary • - JavaScript handles browser events • - Events include click, type, hover, etc. • - Can use inline or JS code • - Makes web pages interactive
  • 15. Questions / Thank You • - Any questions? • - Thanks for your attention! • - JavaScript makes web fun! • - Happy coding!