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

PPTX
JavaScript_Event_Handling_Presentation.pptx
PPTX
Upstate CSCI 450 WebDev Chapter 4
PDF
Web 5 | JavaScript Events
PPTX
GDG On Campus NBNSCOE Web Development Workshop Day 2 : JavaScript and DOM
PDF
Javascript talk1
PPTX
types of events in JS
PPTX
5 .java script events
PPTX
Upstate CSCI 450 WebDev Chapter 4
JavaScript_Event_Handling_Presentation.pptx
Upstate CSCI 450 WebDev Chapter 4
Web 5 | JavaScript Events
GDG On Campus NBNSCOE Web Development Workshop Day 2 : JavaScript and DOM
Javascript talk1
types of events in JS
5 .java script events
Upstate CSCI 450 WebDev Chapter 4

Similar to JavaScript_Event_Handling_Updated_______ (20)

PPTX
Event In JavaScript
PPTX
Learn Javascript Basics
PPTX
Javascript 2
PDF
JavaScript
PDF
JavaScript
PPTX
FYBSC IT Web Programming Unit III Events and Event Handlers
PPTX
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
PDF
JavaScript - Chapter 11 - Events
PPTX
Lesson 205 07 oct13-1500-ay
PPT
Document_Object_Model_in_javaScript..................................ppt
PPT
Event Programming JavaScript
PPT
INTRO TO JAVASCRIPT basic to adcance.ppt
PPT
javascript Event Handling and introduction to event.ppt
PPTX
Introduction to JavaScript DOM and User Input.pptx
PPT
Learn javascript easy steps
PDF
Introduction to web programming with JavaScript
PPTX
Dom(document object model)
PPS
CS101- Introduction to Computing- Lecture 32
PPTX
Javascript note for engineering notes.pptx
Event In JavaScript
Learn Javascript Basics
Javascript 2
JavaScript
JavaScript
FYBSC IT Web Programming Unit III Events and Event Handlers
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
JavaScript - Chapter 11 - Events
Lesson 205 07 oct13-1500-ay
Document_Object_Model_in_javaScript..................................ppt
Event Programming JavaScript
INTRO TO JAVASCRIPT basic to adcance.ppt
javascript Event Handling and introduction to event.ppt
Introduction to JavaScript DOM and User Input.pptx
Learn javascript easy steps
Introduction to web programming with JavaScript
Dom(document object model)
CS101- Introduction to Computing- Lecture 32
Javascript note for engineering notes.pptx
Ad

Recently uploaded (20)

PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
English Language Teaching from Post-.pdf
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
How to Manage Bill Control Policy in Odoo 18
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Open folder Downloads.pdf yes yes ges yes
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
IMMUNIZATION PROGRAMME pptx
Open Quiz Monsoon Mind Game Final Set.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Open Quiz Monsoon Mind Game Prelims.pptx
O7-L3 Supply Chain Operations - ICLT Program
Renaissance Architecture: A Journey from Faith to Humanism
English Language Teaching from Post-.pdf
How to Manage Loyalty Points in Odoo 18 Sales
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
How to Manage Bill Control Policy in Odoo 18
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Open folder Downloads.pdf yes yes ges yes
Cardiovascular Pharmacology for pharmacy students.pptx
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
Introduction and Scope of Bichemistry.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
How to Manage Starshipit in Odoo 18 - Odoo Slides
IMMUNIZATION PROGRAMME pptx
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!