SlideShare a Scribd company logo
An Introduction to jQuery
Pooja Saxena
Topics to cover
2
 Introduction
 Features
 Selectors
 Animations
 Events
 Manipulating HTML/CSS
 Traversing
 Ajax
What is jQuery?
3
 Is a free , open Javascript library
 Founded in 2006 with the motto - Write
Less - Do More
 What it does - Simplifies the task of
creating highly responsive web pages
 Not at all related to Java
 Works across modern browsers
 Can be enabled in your page by
including reference to jQuery library file
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
Typical Usage
4
 HTML/DOM manipulation
 CSS manipulation
 Event handling
 Animating
 Traversing
 Ajax interactions for rapid web
development
Selectors
jQuery selectors start with the dollar sign and − $().
$() is a synonym of jQuery()
 Name -Selects all elements which match with the given
element Name.
 #ID -Selects a single element which matches with the given
ID.
 .Class -Selects all elements which match with the given
Class.
 Universal (*) - Selects all elements available in a DOM.
 Multiple Elements E, F, G - Selects the combined results of all
the specified selectors E, F or G.
5
Animations
 jQuery provides several techniques for adding animation to a
web page to craft sophisticated custom effects.
 Frequently used effects are built into jQuery as methods that
you can call on any jQuery object.
◦ .show() Show the selected elements.
◦ .hide() Hide the selected elements.
◦ .fadeIn() Animate the opacity of the selected elements to
100%.
◦ .fadeOut() Animate the opacity of the selected elements to 0%.
◦ .slideDown() Display the selected elements with a vertical sliding
motion.
◦ .slideUp() Hide the selected elements with a vertical sliding
motion.
◦ .toggle() Show or hide the selected elements with a vertical
sliding motion, depending on whether the elements are currently
visible.
6
Events
 What are Events?
◦ An event represents the precise moment
when some action happens that can be
detected by your Web Application
 Examples:
◦ Mouse click
◦ Web page loading
◦ Mouse over an element
◦ Submitting an HTML form
◦ A keystroke on your keyboard. Etc.
7
Manipulating HTML/CSS
8
 JQuery provides methods to manipulate DOM/CSS in efficient
way.
 Almost all methods acts as getter or setter for HTML
element's attribute
 DOM manipulation includes
◦ Add, Remove or modify any element or its attribute
 CSS manipulation includes
◦ Altering any of the style properties of DOM elments
Traversing
9
 Used to filter out elements from a document based on given
conditions.
 Some common methods which are used for traversing are :-
◦ children() Returns all direct children of the selected element
◦ closest() Returns the first ancestor of the selected element
◦ each() Executes a function for each matched element
◦ eq() Returns an element with a specific index number of the
selected elements
◦ find() Returns descendant elements of the selected element
◦ first() Returns the first element of the selected elements
◦ last() Returns the last element of the selected elements
◦ next() Returns the next sibling element of the selected element
◦ parent() Returns the direct parent element of the selected element
◦ prev() Returns the previous sibling element of the selected element
Ajax
 $.get( url, [data], [callback], [type] )
◦ Requests data from the server with an HTTP GET request.
 $.getJSON( url, [data], [callback] )
◦ Load JSON data using an HTTP GET request.
 $.post( url, [data], [callback], [type] )
◦ Requests data from the server using an HTTP POST request.
 $.ajax( options )
◦ Load a remote page using an HTTP request. Can be called for
get/post/put/delete requests
 serialize( )
◦ Called on forms usually before sending request to server. It creates a URL
encoded text string by serializing form values.
 serializeArray( )
◦ Serializes all forms and form elements like the .serialize() method but
returns a JSON data structure for you to work with.
10
Examples
https://jsfiddle.net/1jrvtwcq/20/

More Related Content

What's hot

Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
Ahmed Elharouny
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
Narendra Dabhi
 
JQuery
JQueryJQuery
Jquery library
Jquery libraryJquery library
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
Richard Martens
 
J Query Public
J Query PublicJ Query Public
J Query Public
pradeepsilamkoti
 
Introduction to JQuery
Introduction to JQueryIntroduction to JQuery
Introduction to JQuery
Muhammad Afzal Qureshi
 
Jqueryppt (1)
Jqueryppt (1)Jqueryppt (1)
Jqueryppt (1)
AndreaSmile06
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
Arwid Bancewicz
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
Igor Ognichenko
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
Kamil Augustynowicz
 
JQuery
JQueryJQuery
JQuery
Jacob Nelson
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Efficient use of jQuery selector
Efficient use of jQuery selectorEfficient use of jQuery selector
Efficient use of jQuery selector
chandrashekher786
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
Wildan Maulana
 
Jquery for Beginners
Jquery for BeginnersJquery for Beginners
Jquery for Beginners
Mohd Abdul Baquee
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
Umeshwaran V
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
Edureka!
 
Jquery
JqueryJquery

What's hot (20)

Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
JQuery
JQueryJQuery
JQuery
 
Jquery library
Jquery libraryJquery library
Jquery library
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
Introduction to JQuery
Introduction to JQueryIntroduction to JQuery
Introduction to JQuery
 
Jqueryppt (1)
Jqueryppt (1)Jqueryppt (1)
Jqueryppt (1)
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11Angular js 2.0, ng poznań 20.11
Angular js 2.0, ng poznań 20.11
 
JQuery
JQueryJQuery
JQuery
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
Efficient use of jQuery selector
Efficient use of jQuery selectorEfficient use of jQuery selector
Efficient use of jQuery selector
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Jquery for Beginners
Jquery for BeginnersJquery for Beginners
Jquery for Beginners
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Jquery
JqueryJquery
Jquery
 

Similar to jQuery basics for Beginners

JQuery
JQueryJQuery
JQuery
DevTalk
 
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
Manoj Bhuva
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Divakar Gu
 
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdfUnit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
RAVALCHIRAG1
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptx
Stefan Oprea
 
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
James Johnson
 
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
James Johnson
 
jQuery quick tuts
jQuery quick tutsjQuery quick tuts
jQuery quick tuts
Nasa Vietnam
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Zeeshan Khan
 
jQuery
jQueryjQuery
J query training
J query trainingJ query training
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
EPAM Systems
 
Web Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONSWeb Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONS
RSolutions
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptx
AditiPawale1
 
jQuery besic
jQuery besicjQuery besic
jQuery besic
Syeful Islam
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
Mohammad Usman
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
azz71
 
J query
J queryJ query
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
AnamikaRai59
 
jQuery
jQueryjQuery
jQuery
Vishwa Mohan
 

Similar to jQuery basics for Beginners (20)

JQuery
JQueryJQuery
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
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdfUnit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptx
 
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
 
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 quick tuts
jQuery quick tutsjQuery quick tuts
jQuery quick tuts
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 
J query training
J query trainingJ query training
J query training
 
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
 
Web Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONSWeb Development Course - JQuery by RSOLUTIONS
Web Development Course - JQuery by RSOLUTIONS
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptx
 
jQuery besic
jQuery besicjQuery besic
jQuery besic
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
 
J query
J queryJ query
J query
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
jQuery
jQueryjQuery
jQuery
 

Recently uploaded

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 

Recently uploaded (20)

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 

jQuery basics for Beginners

  • 1. An Introduction to jQuery Pooja Saxena
  • 2. Topics to cover 2  Introduction  Features  Selectors  Animations  Events  Manipulating HTML/CSS  Traversing  Ajax
  • 3. What is jQuery? 3  Is a free , open Javascript library  Founded in 2006 with the motto - Write Less - Do More  What it does - Simplifies the task of creating highly responsive web pages  Not at all related to Java  Works across modern browsers  Can be enabled in your page by including reference to jQuery library file <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
  • 4. Typical Usage 4  HTML/DOM manipulation  CSS manipulation  Event handling  Animating  Traversing  Ajax interactions for rapid web development
  • 5. Selectors jQuery selectors start with the dollar sign and − $(). $() is a synonym of jQuery()  Name -Selects all elements which match with the given element Name.  #ID -Selects a single element which matches with the given ID.  .Class -Selects all elements which match with the given Class.  Universal (*) - Selects all elements available in a DOM.  Multiple Elements E, F, G - Selects the combined results of all the specified selectors E, F or G. 5
  • 6. Animations  jQuery provides several techniques for adding animation to a web page to craft sophisticated custom effects.  Frequently used effects are built into jQuery as methods that you can call on any jQuery object. ◦ .show() Show the selected elements. ◦ .hide() Hide the selected elements. ◦ .fadeIn() Animate the opacity of the selected elements to 100%. ◦ .fadeOut() Animate the opacity of the selected elements to 0%. ◦ .slideDown() Display the selected elements with a vertical sliding motion. ◦ .slideUp() Hide the selected elements with a vertical sliding motion. ◦ .toggle() Show or hide the selected elements with a vertical sliding motion, depending on whether the elements are currently visible. 6
  • 7. Events  What are Events? ◦ An event represents the precise moment when some action happens that can be detected by your Web Application  Examples: ◦ Mouse click ◦ Web page loading ◦ Mouse over an element ◦ Submitting an HTML form ◦ A keystroke on your keyboard. Etc. 7
  • 8. Manipulating HTML/CSS 8  JQuery provides methods to manipulate DOM/CSS in efficient way.  Almost all methods acts as getter or setter for HTML element's attribute  DOM manipulation includes ◦ Add, Remove or modify any element or its attribute  CSS manipulation includes ◦ Altering any of the style properties of DOM elments
  • 9. Traversing 9  Used to filter out elements from a document based on given conditions.  Some common methods which are used for traversing are :- ◦ children() Returns all direct children of the selected element ◦ closest() Returns the first ancestor of the selected element ◦ each() Executes a function for each matched element ◦ eq() Returns an element with a specific index number of the selected elements ◦ find() Returns descendant elements of the selected element ◦ first() Returns the first element of the selected elements ◦ last() Returns the last element of the selected elements ◦ next() Returns the next sibling element of the selected element ◦ parent() Returns the direct parent element of the selected element ◦ prev() Returns the previous sibling element of the selected element
  • 10. Ajax  $.get( url, [data], [callback], [type] ) ◦ Requests data from the server with an HTTP GET request.  $.getJSON( url, [data], [callback] ) ◦ Load JSON data using an HTTP GET request.  $.post( url, [data], [callback], [type] ) ◦ Requests data from the server using an HTTP POST request.  $.ajax( options ) ◦ Load a remote page using an HTTP request. Can be called for get/post/put/delete requests  serialize( ) ◦ Called on forms usually before sending request to server. It creates a URL encoded text string by serializing form values.  serializeArray( ) ◦ Serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with. 10

Editor's Notes

  1. After first session add lines