際際滷

際際滷Share a Scribd company logo
INTRODUCTION TO
JAVASCRIPT DOM AND
USER INPUT
By
Gevita Chinnaiah
OVERVIEW
 Introduction to JavaScript
 What the DOM is
 Importance of handling user input
INTRODUCTION TO JAVASCRIPT
 JavaScript is a popular programming language
that is primarily used to create interactive and
dynamic features on websites.
 JavaScript has grown into a powerful tool used in
many different contexts, including server-side
programming, mobile app development, and even
desktop applications.
WHAT IS THE DOM?
 The Document Object Model (DOM) is a
programming interface provided by browsers that
allows scripts to dynamically access and update
the content, structure, and style of a document.
 DOM represents an HTML (or XML) document
as a tree structure wherein each node is an object
representing a part of the document
DOM REPRESENTS AN HTML
DOCUMENT
WHY MANIPULATE THE DOM?
 Manipulating the Document Object Model (DOM)
is a Important aspect of creating interactive and
dynamic web applications.
 Dynamic Content Updates
 Real-time Interactions
 User Feedback:
 Interactive User Interfaces (UIs)
 Rich Interactions
 Personalization
 Accessibility Enhancements
ACCESSING THE DOM
 The Document Object Model (DOM) is a
programming interface that allows scripts to
update the content, structure, and style of a
document.
 DOM provides a structured representation of the
HTML or XML document
 JavaScript interacts with the DOM to
dynamically manipulate web pages.
document
METHODS FOR ACCESSING
ELEMENTS
 getElementById(id):
 Usage: document.getElementById('header').
 Returns: The first element with the given ID, or null if no
such element exists.
 getElementsByClassName(className):
 Usage: document.getElementsByClassName('active').
 Returns: A live HTMLCollection of elements with the given
class names. It updates automatically when elements are
added or removed.
 querySelector(selector):
 Usage: document.querySelector('.menu-item') for classes,
document.querySelector('#menu') for IDs, or
document.querySelector('div') for tags.
 Returns: The first element that matches the specified CSS
selector, or null if no matches are found.
ADVANCED SELECTION WITH
QUERYSELECTORALL
 Method
 querySelectorAll(selector)
 Purpose
 Similar to querySelector, but selects all elements that
match the specified CSS selector.
 Usage
 document.querySelectorAll('.highlight').
 Returns
 A static NodeList containing all the elements
that match the selector. Unlike HTMLCollection,
NodeList does not update automatically.
COMMON DOM METHODS
 1. innerHTML
 Example: element.innerHTML = "<strong>Hello World!</strong>";
sets the inner HTML of the element to include a bolded "Hello
World".
 2. textContent
 Example: element.textContent = "Hello World"; updates the text
within an element, removing any existing HTML or text formatting.
 3. createElement
 Example: var newDiv = document.createElement('div'); creates a
new <div> element which can later be added to the DOM.
 4. appendChild
 Example: document.body.appendChild(newDiv); adds the
previously created <div> element to the body of the document.
 5. removeChild
 Example: document.body.removeChild(existingDiv); removes the
specified existingDiv element from the body of the document.
USER EVENTS IN JAVASCRIPT
 In JavaScript, events are actions or occurrences
that happen in the browser, often as a result of
user interaction or system-generated triggers
 Common Event Types:
 Click Event
 Load Event
 Input Event
 Submit Event
 Mouse Events (e.g., mouseover, mouseout)
EVENT LISTENERS
 Event listeners in JavaScript are used to respond
to various events that occur on HTML elements,
such as clicks, mouse movements, keypresses,
form submissions.
 The addEventListener method is a basic tool for
attaching event listeners to elements in the
DOM.
EVENT LISTENERS AND
ADDEVENTLISTENER
 Event listeners allow JavaScript to "listen" for
specific events on HTML elements and execute
code in response to those events.
 The addEventListener method is used to register
event handlers on HTML elements.
 Syntax of addEventListener:
ADDING AN EVENT LISTENER TO
A BUTTON
 Consider an HTML button element with the id
"myButton":
 use addEventListener to attach a click event
listener.
HANDLING FORM INPUT
 Handling form input in JavaScript involves
capturing user input from HTML form elements
and responding to user actions such as typing or
selecting options.
 Input
 Change events.
INPUT EVENT
 The input event is triggered whenever the value
of an input field changes.
CHANGE EVENT
 The change event is triggered when the value of
an input field changes and then the element loses
focus.
PRACTICAL EXAMPLE:
INTERACTIVE FORM
1. Dynamic Form Validation
2. Live Character Count
3. Dropdown Selection
THANK YOU

More Related Content

Similar to Introduction to JavaScript DOM and User Input.pptx (20)

Windows Forms 2.0 Enhancements
Windows Forms 2.0 EnhancementsWindows Forms 2.0 Enhancements
Windows Forms 2.0 Enhancements
guestd115f
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
IMC Institute
Javascript dom
Javascript domJavascript dom
Javascript dom
Muthuganesh S
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
Randy Connolly
Scripting languages
Scripting languagesScripting languages
Scripting languages
teach4uin
WPF Controls
WPF ControlsWPF Controls
WPF Controls
Doncho Minkov
WPF Fundamentals
WPF FundamentalsWPF Fundamentals
WPF Fundamentals
Our Community Exchange LLC
Asp objects
Asp objectsAsp objects
Asp objects
RajaRajeswari22
Android Application Development Programming
Android Application Development ProgrammingAndroid Application Development Programming
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
Jquery Tutorials for designing Dynamic Web Site
Jquery Tutorials for designing Dynamic Web SiteJquery Tutorials for designing Dynamic Web Site
Jquery Tutorials for designing Dynamic Web Site
Pyingkodi Maran
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
Abhishek Sur
Presentation
PresentationPresentation
Presentation
Chetan Kataria
Javascript
Javascript Javascript
Javascript
poojanov04
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptxUnit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
Abhishek Sur
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfflutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
RubenGray1
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
AnamikaRai59
Implement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docxImplement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docx
mckerliejonelle
Electronics is a scientific and engineering discipline that studies and appli...
Electronics is a scientific and engineering discipline that studies and appli...Electronics is a scientific and engineering discipline that studies and appli...
Electronics is a scientific and engineering discipline that studies and appli...
JANARTHANANS22
Windows Forms 2.0 Enhancements
Windows Forms 2.0 EnhancementsWindows Forms 2.0 Enhancements
Windows Forms 2.0 Enhancements
guestd115f
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
IMC Institute
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
Randy Connolly
Scripting languages
Scripting languagesScripting languages
Scripting languages
teach4uin
Jquery Tutorials for designing Dynamic Web Site
Jquery Tutorials for designing Dynamic Web SiteJquery Tutorials for designing Dynamic Web Site
Jquery Tutorials for designing Dynamic Web Site
Pyingkodi Maran
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
Abhishek Sur
Javascript
Javascript Javascript
Javascript
poojanov04
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptxUnit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
Abhishek Sur
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfflutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
RubenGray1
Implement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docxImplement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docx
mckerliejonelle
Electronics is a scientific and engineering discipline that studies and appli...
Electronics is a scientific and engineering discipline that studies and appli...Electronics is a scientific and engineering discipline that studies and appli...
Electronics is a scientific and engineering discipline that studies and appli...
JANARTHANANS22

More from GevitaChinnaiah (20)

Building a To-Do List App lecture 1.pptx
Building a To-Do List App lecture 1.pptxBuilding a To-Do List App lecture 1.pptx
Building a To-Do List App lecture 1.pptx
GevitaChinnaiah
Software Quality and Testing note 1.pptx
Software Quality and Testing note 1.pptxSoftware Quality and Testing note 1.pptx
Software Quality and Testing note 1.pptx
GevitaChinnaiah
391Lecture0909 Vision control of git.ppt
391Lecture0909 Vision control of git.ppt391Lecture0909 Vision control of git.ppt
391Lecture0909 Vision control of git.ppt
GevitaChinnaiah
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
Software Programming with Python II.pptx
Software Programming with Python II.pptxSoftware Programming with Python II.pptx
Software Programming with Python II.pptx
GevitaChinnaiah
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.ppt
GevitaChinnaiah
Install an Operating System.pptx
Install an Operating System.pptxInstall an Operating System.pptx
Install an Operating System.pptx
GevitaChinnaiah
Solve Stop Code Memory Management on Windows.pptx
Solve Stop Code Memory Management on Windows.pptxSolve Stop Code Memory Management on Windows.pptx
Solve Stop Code Memory Management on Windows.pptx
GevitaChinnaiah
windows memory management.pptx
windows memory management.pptxwindows memory management.pptx
windows memory management.pptx
GevitaChinnaiah
Introduction to Database Management.pptx
Introduction to Database Management.pptxIntroduction to Database Management.pptx
Introduction to Database Management.pptx
GevitaChinnaiah
OPERATING SYSTEM CHAPTER 3.ppt
OPERATING SYSTEM CHAPTER 3.pptOPERATING SYSTEM CHAPTER 3.ppt
OPERATING SYSTEM CHAPTER 3.ppt
GevitaChinnaiah
Lecture 3 React Native with Database.pptx
Lecture 3 React Native with Database.pptxLecture 3 React Native with Database.pptx
Lecture 3 React Native with Database.pptx
GevitaChinnaiah
Database Management System (DBMS).pptx
Database Management System (DBMS).pptxDatabase Management System (DBMS).pptx
Database Management System (DBMS).pptx
GevitaChinnaiah
Operating System chapter 1.pptx
Operating System chapter 1.pptxOperating System chapter 1.pptx
Operating System chapter 1.pptx
GevitaChinnaiah
Lecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptxLecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptx
GevitaChinnaiah
Lecture 1 Introduction to React Native.pptx
Lecture 1 Introduction to React Native.pptxLecture 1 Introduction to React Native.pptx
Lecture 1 Introduction to React Native.pptx
GevitaChinnaiah
Understanding Applications.pptx
Understanding Applications.pptxUnderstanding Applications.pptx
Understanding Applications.pptx
GevitaChinnaiah
Operating System 2.pptx
Operating System 2.pptxOperating System 2.pptx
Operating System 2.pptx
GevitaChinnaiah
Operating System 1.pptx
Operating System 1.pptxOperating System 1.pptx
Operating System 1.pptx
GevitaChinnaiah
INTRODUCTION TO DATABASE AND QUERING.pptx
INTRODUCTION TO DATABASE AND QUERING.pptxINTRODUCTION TO DATABASE AND QUERING.pptx
INTRODUCTION TO DATABASE AND QUERING.pptx
GevitaChinnaiah
Building a To-Do List App lecture 1.pptx
Building a To-Do List App lecture 1.pptxBuilding a To-Do List App lecture 1.pptx
Building a To-Do List App lecture 1.pptx
GevitaChinnaiah
Software Quality and Testing note 1.pptx
Software Quality and Testing note 1.pptxSoftware Quality and Testing note 1.pptx
Software Quality and Testing note 1.pptx
GevitaChinnaiah
391Lecture0909 Vision control of git.ppt
391Lecture0909 Vision control of git.ppt391Lecture0909 Vision control of git.ppt
391Lecture0909 Vision control of git.ppt
GevitaChinnaiah
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
Software Programming with Python II.pptx
Software Programming with Python II.pptxSoftware Programming with Python II.pptx
Software Programming with Python II.pptx
GevitaChinnaiah
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.ppt
GevitaChinnaiah
Install an Operating System.pptx
Install an Operating System.pptxInstall an Operating System.pptx
Install an Operating System.pptx
GevitaChinnaiah
Solve Stop Code Memory Management on Windows.pptx
Solve Stop Code Memory Management on Windows.pptxSolve Stop Code Memory Management on Windows.pptx
Solve Stop Code Memory Management on Windows.pptx
GevitaChinnaiah
windows memory management.pptx
windows memory management.pptxwindows memory management.pptx
windows memory management.pptx
GevitaChinnaiah
Introduction to Database Management.pptx
Introduction to Database Management.pptxIntroduction to Database Management.pptx
Introduction to Database Management.pptx
GevitaChinnaiah
OPERATING SYSTEM CHAPTER 3.ppt
OPERATING SYSTEM CHAPTER 3.pptOPERATING SYSTEM CHAPTER 3.ppt
OPERATING SYSTEM CHAPTER 3.ppt
GevitaChinnaiah
Lecture 3 React Native with Database.pptx
Lecture 3 React Native with Database.pptxLecture 3 React Native with Database.pptx
Lecture 3 React Native with Database.pptx
GevitaChinnaiah
Database Management System (DBMS).pptx
Database Management System (DBMS).pptxDatabase Management System (DBMS).pptx
Database Management System (DBMS).pptx
GevitaChinnaiah
Operating System chapter 1.pptx
Operating System chapter 1.pptxOperating System chapter 1.pptx
Operating System chapter 1.pptx
GevitaChinnaiah
Lecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptxLecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptx
GevitaChinnaiah
Lecture 1 Introduction to React Native.pptx
Lecture 1 Introduction to React Native.pptxLecture 1 Introduction to React Native.pptx
Lecture 1 Introduction to React Native.pptx
GevitaChinnaiah
Understanding Applications.pptx
Understanding Applications.pptxUnderstanding Applications.pptx
Understanding Applications.pptx
GevitaChinnaiah
Operating System 2.pptx
Operating System 2.pptxOperating System 2.pptx
Operating System 2.pptx
GevitaChinnaiah
Operating System 1.pptx
Operating System 1.pptxOperating System 1.pptx
Operating System 1.pptx
GevitaChinnaiah
INTRODUCTION TO DATABASE AND QUERING.pptx
INTRODUCTION TO DATABASE AND QUERING.pptxINTRODUCTION TO DATABASE AND QUERING.pptx
INTRODUCTION TO DATABASE AND QUERING.pptx
GevitaChinnaiah

Recently uploaded (20)

Wilcom Embroidery Studio Crack Version 2025?
Wilcom Embroidery Studio Crack Version 2025?Wilcom Embroidery Studio Crack Version 2025?
Wilcom Embroidery Studio Crack Version 2025?
Designer
Food delivery services and management.pdf
Food delivery services and management.pdfFood delivery services and management.pdf
Food delivery services and management.pdf
vasanthselvaraj19200
sloa060tttttttttttttttttttttttttttttttt.pdf
sloa060tttttttttttttttttttttttttttttttt.pdfsloa060tttttttttttttttttttttttttttttttt.pdf
sloa060tttttttttttttttttttttttttttttttt.pdf
aberagirma811
Dropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World ApplicationsDropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World Applications
jpopulimroch
Fire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
Fire Extinguisher SafetyjhgcghkjvkjvhmhbvkjhvFire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
Fire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
IlgarKarimov3
Greenery-Palette Pitch Deck by 際際滷sgo.pptx
Greenery-Palette Pitch Deck by 際際滷sgo.pptxGreenery-Palette Pitch Deck by 際際滷sgo.pptx
Greenery-Palette Pitch Deck by 際際滷sgo.pptx
rsaldanach0
89_Theories_ of Child_ Development.pptxhhhh
89_Theories_ of Child_ Development.pptxhhhh89_Theories_ of Child_ Development.pptxhhhh
89_Theories_ of Child_ Development.pptxhhhh
Noorien3
JAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
JAIN ARCHITECTURE AND BUDDHIST - Copy.pptJAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
JAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
prakriti123
Introduction_to_Verilog (1).pptxzhdYfzhfzy
Introduction_to_Verilog (1).pptxzhdYfzhfzyIntroduction_to_Verilog (1).pptxzhdYfzhfzy
Introduction_to_Verilog (1).pptxzhdYfzhfzy
hereshmurugan007
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
SithamparanaathanPir
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
BarusRa
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptxtabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
GitaWardhani1
Architecture student model-making images
Architecture student model-making  imagesArchitecture student model-making  images
Architecture student model-making images
mumtahatabassum1842
Excellenseaa 126 HOUSING REFERENCES.pptx
Excellenseaa 126 HOUSING REFERENCES.pptxExcellenseaa 126 HOUSING REFERENCES.pptx
Excellenseaa 126 HOUSING REFERENCES.pptx
aaryandoshii4
Promoting Sustainable Development of Hill Areas --Issues and Options
Promoting Sustainable Development of Hill Areas --Issues and OptionsPromoting Sustainable Development of Hill Areas --Issues and Options
Promoting Sustainable Development of Hill Areas --Issues and Options
JIT KUMAR GUPTA
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdfOLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
DimejiFakorede
Exper_Machine Learning Experimental data.ppt
Exper_Machine Learning Experimental data.pptExper_Machine Learning Experimental data.ppt
Exper_Machine Learning Experimental data.ppt
ArpitaPatel527902
Romeo C. Reroma Jr. Portfolio (2d and 3d)
Romeo C. Reroma Jr. Portfolio (2d and 3d)Romeo C. Reroma Jr. Portfolio (2d and 3d)
Romeo C. Reroma Jr. Portfolio (2d and 3d)
romeoreromajr
Dropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World ApplicationsDropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World Applications
jpopulimroch
Colorful Clean Project Planning Concept Map Graph.pptx
Colorful Clean Project Planning Concept Map Graph.pptxColorful Clean Project Planning Concept Map Graph.pptx
Colorful Clean Project Planning Concept Map Graph.pptx
JamAmbros
Wilcom Embroidery Studio Crack Version 2025?
Wilcom Embroidery Studio Crack Version 2025?Wilcom Embroidery Studio Crack Version 2025?
Wilcom Embroidery Studio Crack Version 2025?
Designer
Food delivery services and management.pdf
Food delivery services and management.pdfFood delivery services and management.pdf
Food delivery services and management.pdf
vasanthselvaraj19200
sloa060tttttttttttttttttttttttttttttttt.pdf
sloa060tttttttttttttttttttttttttttttttt.pdfsloa060tttttttttttttttttttttttttttttttt.pdf
sloa060tttttttttttttttttttttttttttttttt.pdf
aberagirma811
Dropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World ApplicationsDropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World Applications
jpopulimroch
Fire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
Fire Extinguisher SafetyjhgcghkjvkjvhmhbvkjhvFire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
Fire Extinguisher Safetyjhgcghkjvkjvhmhbvkjhv
IlgarKarimov3
Greenery-Palette Pitch Deck by 際際滷sgo.pptx
Greenery-Palette Pitch Deck by 際際滷sgo.pptxGreenery-Palette Pitch Deck by 際際滷sgo.pptx
Greenery-Palette Pitch Deck by 際際滷sgo.pptx
rsaldanach0
89_Theories_ of Child_ Development.pptxhhhh
89_Theories_ of Child_ Development.pptxhhhh89_Theories_ of Child_ Development.pptxhhhh
89_Theories_ of Child_ Development.pptxhhhh
Noorien3
JAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
JAIN ARCHITECTURE AND BUDDHIST - Copy.pptJAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
JAIN ARCHITECTURE AND BUDDHIST - Copy.ppt
prakriti123
Introduction_to_Verilog (1).pptxzhdYfzhfzy
Introduction_to_Verilog (1).pptxzhdYfzhfzyIntroduction_to_Verilog (1).pptxzhdYfzhfzy
Introduction_to_Verilog (1).pptxzhdYfzhfzy
hereshmurugan007
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
際際滷Egg_83136-Ramadan PowerPoint Presentation PPT.pptx
SithamparanaathanPir
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
Attract Project - SOIL SKIN, The SOILSKIN project aims to create renewable ga...
BarusRa
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptxtabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
tabel kuma pneumoniiiiiiiiiiiiiiiiiiiiiiiii.pptx
GitaWardhani1
Architecture student model-making images
Architecture student model-making  imagesArchitecture student model-making  images
Architecture student model-making images
mumtahatabassum1842
Excellenseaa 126 HOUSING REFERENCES.pptx
Excellenseaa 126 HOUSING REFERENCES.pptxExcellenseaa 126 HOUSING REFERENCES.pptx
Excellenseaa 126 HOUSING REFERENCES.pptx
aaryandoshii4
Promoting Sustainable Development of Hill Areas --Issues and Options
Promoting Sustainable Development of Hill Areas --Issues and OptionsPromoting Sustainable Development of Hill Areas --Issues and Options
Promoting Sustainable Development of Hill Areas --Issues and Options
JIT KUMAR GUPTA
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdfOLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
OLADIMEJI FAKOREDE DESIGN REALISATION REPORT.pdf
DimejiFakorede
Exper_Machine Learning Experimental data.ppt
Exper_Machine Learning Experimental data.pptExper_Machine Learning Experimental data.ppt
Exper_Machine Learning Experimental data.ppt
ArpitaPatel527902
Romeo C. Reroma Jr. Portfolio (2d and 3d)
Romeo C. Reroma Jr. Portfolio (2d and 3d)Romeo C. Reroma Jr. Portfolio (2d and 3d)
Romeo C. Reroma Jr. Portfolio (2d and 3d)
romeoreromajr
Dropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World ApplicationsDropbox Sharing Methods: Real-World Applications
Dropbox Sharing Methods: Real-World Applications
jpopulimroch
Colorful Clean Project Planning Concept Map Graph.pptx
Colorful Clean Project Planning Concept Map Graph.pptxColorful Clean Project Planning Concept Map Graph.pptx
Colorful Clean Project Planning Concept Map Graph.pptx
JamAmbros

Introduction to JavaScript DOM and User Input.pptx

  • 1. INTRODUCTION TO JAVASCRIPT DOM AND USER INPUT By Gevita Chinnaiah
  • 2. OVERVIEW Introduction to JavaScript What the DOM is Importance of handling user input
  • 3. INTRODUCTION TO JAVASCRIPT JavaScript is a popular programming language that is primarily used to create interactive and dynamic features on websites. JavaScript has grown into a powerful tool used in many different contexts, including server-side programming, mobile app development, and even desktop applications.
  • 4. WHAT IS THE DOM? The Document Object Model (DOM) is a programming interface provided by browsers that allows scripts to dynamically access and update the content, structure, and style of a document. DOM represents an HTML (or XML) document as a tree structure wherein each node is an object representing a part of the document
  • 5. DOM REPRESENTS AN HTML DOCUMENT
  • 6. WHY MANIPULATE THE DOM? Manipulating the Document Object Model (DOM) is a Important aspect of creating interactive and dynamic web applications. Dynamic Content Updates Real-time Interactions User Feedback: Interactive User Interfaces (UIs) Rich Interactions Personalization Accessibility Enhancements
  • 7. ACCESSING THE DOM The Document Object Model (DOM) is a programming interface that allows scripts to update the content, structure, and style of a document. DOM provides a structured representation of the HTML or XML document JavaScript interacts with the DOM to dynamically manipulate web pages. document
  • 8. METHODS FOR ACCESSING ELEMENTS getElementById(id): Usage: document.getElementById('header'). Returns: The first element with the given ID, or null if no such element exists. getElementsByClassName(className): Usage: document.getElementsByClassName('active'). Returns: A live HTMLCollection of elements with the given class names. It updates automatically when elements are added or removed. querySelector(selector): Usage: document.querySelector('.menu-item') for classes, document.querySelector('#menu') for IDs, or document.querySelector('div') for tags. Returns: The first element that matches the specified CSS selector, or null if no matches are found.
  • 9. ADVANCED SELECTION WITH QUERYSELECTORALL Method querySelectorAll(selector) Purpose Similar to querySelector, but selects all elements that match the specified CSS selector. Usage document.querySelectorAll('.highlight'). Returns A static NodeList containing all the elements that match the selector. Unlike HTMLCollection, NodeList does not update automatically.
  • 10. COMMON DOM METHODS 1. innerHTML Example: element.innerHTML = "<strong>Hello World!</strong>"; sets the inner HTML of the element to include a bolded "Hello World". 2. textContent Example: element.textContent = "Hello World"; updates the text within an element, removing any existing HTML or text formatting. 3. createElement Example: var newDiv = document.createElement('div'); creates a new <div> element which can later be added to the DOM. 4. appendChild Example: document.body.appendChild(newDiv); adds the previously created <div> element to the body of the document. 5. removeChild Example: document.body.removeChild(existingDiv); removes the specified existingDiv element from the body of the document.
  • 11. USER EVENTS IN JAVASCRIPT In JavaScript, events are actions or occurrences that happen in the browser, often as a result of user interaction or system-generated triggers Common Event Types: Click Event Load Event Input Event Submit Event Mouse Events (e.g., mouseover, mouseout)
  • 12. EVENT LISTENERS Event listeners in JavaScript are used to respond to various events that occur on HTML elements, such as clicks, mouse movements, keypresses, form submissions. The addEventListener method is a basic tool for attaching event listeners to elements in the DOM.
  • 13. EVENT LISTENERS AND ADDEVENTLISTENER Event listeners allow JavaScript to "listen" for specific events on HTML elements and execute code in response to those events. The addEventListener method is used to register event handlers on HTML elements. Syntax of addEventListener:
  • 14. ADDING AN EVENT LISTENER TO A BUTTON Consider an HTML button element with the id "myButton": use addEventListener to attach a click event listener.
  • 15. HANDLING FORM INPUT Handling form input in JavaScript involves capturing user input from HTML form elements and responding to user actions such as typing or selecting options. Input Change events.
  • 16. INPUT EVENT The input event is triggered whenever the value of an input field changes.
  • 17. CHANGE EVENT The change event is triggered when the value of an input field changes and then the element loses focus.
  • 18. PRACTICAL EXAMPLE: INTERACTIVE FORM 1. Dynamic Form Validation 2. Live Character Count 3. Dropdown Selection