SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
Web Technologies – CS 382
Shehzad Aslam
Lecture 5
3 Hrs
 DOM
 Understanding jQuery
 Form validation
 Document object that represent web page
 When page is loaded browser create DOM (tree)
 Defines how to get, add, delete, change HTML elements
 Finding things
 getElementById
 getElementByTagName
 getElementByClassName
 Changing things
 element.innerHTML
 element.attribute
 element.setAttribute(attrib, val)
 element.style.stylename
 Creating elements
 createElement (element)
 removeChild (element)
 appendChild (element)
 See link at end of slide
We see some of them in last
class, and when you are
preparing last assignment
 John Resig invented in Jan 2006
 Cross platform JavaScript library
 Make easier to navigate document DOM (use CSS selectors)
 Provide event handling to DOM rather than HTML event
attribute
 Event handling & call backs done in simple steps
 Easier to write AJAX
 Also have some Effects & animations
 Browsers are programmed to recognize events
 Pageload
 Click
 Mouse movement etc
 Include it online
 http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js
 Or use a specific version
 Include offline
 Download the file & include it
 <script type=“text/javascript” src=“jquery.js”></script>
 Demo 1
 Edit the li
 On double click any li show a textbox there and on losing focus to textbox change
the li contents
 What to do?
 Seems complex if you will use JavaScript
 Two steps
 Select elements for which you want to respond to event
 Assign an event and create a function to run when event occurs
$(„selector‟).event( … );
e.g. $(„#form1‟).submit( … );
$(„selector‟).function( … );
e.g. $(„p‟).html(“change all paragraph contents”);
if user has disabled the JavaScript you can not do anything
Use noscript tag to tell user to enable javascript
 Mouse Events
 Click, dblclick, mousedown, mouseup, mouseover,
mouseout, mousemove
 Document/Window Events
 Load, resize
 Form Events
 Submit, reset, change, focus, blur
 Keyboard Events
 Keypress, keydown
 JQuery Way
 Select element - $(„a‟)
 Assign an event - $(„a‟).mouseover()
 Pass function to event
 $(„a‟).mouseover(MyFunction)
 Or use anonymous function –
 $(„a‟).mouseover(function () { … })
 Demo 1
 Edit the li
 On double click any li show a textbox there and on losing focus to textbox change
the li contents
 What to do?
 Seems complex if you will use JavaScript
 Two ways
 Bind submit event of function (must use)
 Validate each component when user finished entering data (blur event)
 Assign ID to each field to access it
 For getting/setting value of Input, textarea, select
 element.val(); //return element value
 element.val(“some value”); //set element value
 For checking radio button selection
 element.attr(“checked”);
 Selecting all form elements of certain type:
 $(„:text‟)
 Selects all text fields
 Use with :input ( all form elements), :password, :radio, :checkbox, :submit, :image,
:reset, :button, :file, :hidden
 Can use descendant selectors too $(„#signup : text‟)
 Reading
 See jQuery Cheat sheet for
 Assessing HTML DOM document using JavaScript
 https://www.w3schools.com/js/js_htmldom_document.asp
 Practice will get your hand ready for jQuery
 Complete the Assignment

Mais conteúdo relacionado

Mais procurados

The Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingThe Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingYorick Phoenix
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML APIWeb workers | JavaScript | HTML API
Web workers | JavaScript | HTML APIpcnmtutorials
 
Displaying data via onclick event. I have a csv file that I'm attaching to a...
Displaying data via onclick event.  I have a csv file that I'm attaching to a...Displaying data via onclick event.  I have a csv file that I'm attaching to a...
Displaying data via onclick event. I have a csv file that I'm attaching to a...licservernoida
 
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...GeeksLab Odessa
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentationMevin Mohan
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETJames Johnson
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for BeginnersPooja Saxena
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 

Mais procurados (20)

The Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event HandlingThe Fine Art of JavaScript Event Handling
The Fine Art of JavaScript Event Handling
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
Introduction to j_query
Introduction to j_queryIntroduction to j_query
Introduction to j_query
 
JavaScript Libraries
JavaScript LibrariesJavaScript Libraries
JavaScript Libraries
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML APIWeb workers | JavaScript | HTML API
Web workers | JavaScript | HTML API
 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
 
Displaying data via onclick event. I have a csv file that I'm attaching to a...
Displaying data via onclick event.  I have a csv file that I'm attaching to a...Displaying data via onclick event.  I have a csv file that I'm attaching to a...
Displaying data via onclick event. I have a csv file that I'm attaching to a...
 
Web programming
Web programmingWeb programming
Web programming
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
React for WinRT apps
React for WinRT appsReact for WinRT apps
React for WinRT apps
 
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...
JSLab. Ингвар Степанян. "React в разработке нативных WinRT/Windows Phone прил...
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
jQuery besic
jQuery besicjQuery besic
jQuery besic
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for Beginners
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 

Semelhante a Lec 5

A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETJames Johnson
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxAditiPawale1
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript DevelopmentTommy Vercety
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQueryKnoldus Inc.
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperManoj Bhuva
 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaztestingphase
 
jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events WebStackAcademy
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQueryorestJump
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012ghnash
 
How to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuerykolkatageeks
 

Semelhante a Lec 5 (20)

Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Jquery
JqueryJquery
Jquery
 
J query
J queryJ query
J query
 
A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NET
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
J query training
J query trainingJ query training
J query training
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
 
jQuery
jQueryjQuery
jQuery
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java Developer
 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
 
Client Web
Client WebClient Web
Client Web
 
jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
Introduzione JQuery
Introduzione JQueryIntroduzione JQuery
Introduzione JQuery
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012
 
How to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuery
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 

Mais de maamir farooq (20)

Ooad lab1
Ooad lab1Ooad lab1
Ooad lab1
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Php client libray
Php client librayPhp client libray
Php client libray
 
Swiftmailer
SwiftmailerSwiftmailer
Swiftmailer
 
Lect15
Lect15Lect15
Lect15
 
Lec 7
Lec 7Lec 7
Lec 7
 
Lec 6
Lec 6Lec 6
Lec 6
 
J query 1.7 cheat sheet
J query 1.7 cheat sheetJ query 1.7 cheat sheet
J query 1.7 cheat sheet
 
Assignment
AssignmentAssignment
Assignment
 
Java script summary
Java script summaryJava script summary
Java script summary
 
Lec 3
Lec 3Lec 3
Lec 3
 
Lec 2
Lec 2Lec 2
Lec 2
 
Lec 1
Lec 1Lec 1
Lec 1
 
Css summary
Css summaryCss summary
Css summary
 
Manual of image processing lab
Manual of image processing labManual of image processing lab
Manual of image processing lab
 
Session management
Session managementSession management
Session management
 
Data management
Data managementData management
Data management
 
Content provider
Content providerContent provider
Content provider
 
Android sq lite database tutorial
Android sq lite database tutorialAndroid sq lite database tutorial
Android sq lite database tutorial
 

Último

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Lec 5

  • 1. Web Technologies – CS 382 Shehzad Aslam Lecture 5 3 Hrs
  • 2.  DOM  Understanding jQuery  Form validation
  • 3.  Document object that represent web page  When page is loaded browser create DOM (tree)  Defines how to get, add, delete, change HTML elements
  • 4.  Finding things  getElementById  getElementByTagName  getElementByClassName  Changing things  element.innerHTML  element.attribute  element.setAttribute(attrib, val)  element.style.stylename  Creating elements  createElement (element)  removeChild (element)  appendChild (element)  See link at end of slide We see some of them in last class, and when you are preparing last assignment
  • 5.  John Resig invented in Jan 2006  Cross platform JavaScript library  Make easier to navigate document DOM (use CSS selectors)  Provide event handling to DOM rather than HTML event attribute  Event handling & call backs done in simple steps  Easier to write AJAX  Also have some Effects & animations  Browsers are programmed to recognize events  Pageload  Click  Mouse movement etc
  • 6.  Include it online  http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js  Or use a specific version  Include offline  Download the file & include it  <script type=“text/javascript” src=“jquery.js”></script>  Demo 1  Edit the li  On double click any li show a textbox there and on losing focus to textbox change the li contents  What to do?  Seems complex if you will use JavaScript
  • 7.  Two steps  Select elements for which you want to respond to event  Assign an event and create a function to run when event occurs $(„selector‟).event( … ); e.g. $(„#form1‟).submit( … ); $(„selector‟).function( … ); e.g. $(„p‟).html(“change all paragraph contents”); if user has disabled the JavaScript you can not do anything Use noscript tag to tell user to enable javascript
  • 8.  Mouse Events  Click, dblclick, mousedown, mouseup, mouseover, mouseout, mousemove  Document/Window Events  Load, resize  Form Events  Submit, reset, change, focus, blur  Keyboard Events  Keypress, keydown
  • 9.  JQuery Way  Select element - $(„a‟)  Assign an event - $(„a‟).mouseover()  Pass function to event  $(„a‟).mouseover(MyFunction)  Or use anonymous function –  $(„a‟).mouseover(function () { … })
  • 10.  Demo 1  Edit the li  On double click any li show a textbox there and on losing focus to textbox change the li contents  What to do?  Seems complex if you will use JavaScript
  • 11.  Two ways  Bind submit event of function (must use)  Validate each component when user finished entering data (blur event)  Assign ID to each field to access it  For getting/setting value of Input, textarea, select  element.val(); //return element value  element.val(“some value”); //set element value  For checking radio button selection  element.attr(“checked”);  Selecting all form elements of certain type:  $(„:text‟)  Selects all text fields  Use with :input ( all form elements), :password, :radio, :checkbox, :submit, :image, :reset, :button, :file, :hidden  Can use descendant selectors too $(„#signup : text‟)
  • 12.  Reading  See jQuery Cheat sheet for  Assessing HTML DOM document using JavaScript  https://www.w3schools.com/js/js_htmldom_document.asp  Practice will get your hand ready for jQuery  Complete the Assignment