SlideShare une entreprise Scribd logo
1  sur  16
JQuery
SCRIPTING LANGUAGES
JAVASCRIPT
Kumar Gaurav
k10gaurav@gmail.com
JQuery
 Powerful JavaScript library
 Simplify common JavaScript tasks
 Access parts of a page
 using CSS or XPath-like expressions
 Modify the appearance of a page
 Alter the content of a page
 Change the user’s interaction with a page
 Add animation to a page
 Provide AJAX support
 Abstract away browser quirks
Introductory Sample
<html>
<body>
<h1>Cities of the World</h1>
<dl>
<dt>Paris</dt><dd>Chic,
fashionable, expensive
rude</dd>
<dt>Sydney</dt><dd>Opera
house but no culture,
Mardi Gras,
fireworks</dd>
</dl>
</body>
</html>
h1 {font-size: 2.5em;
margin-bottom: 0;}
.emphasize {font-style:
italic; color:red;}
Basic JQuery
 Selecting part of document is fundamental
operation
 A JQuery object is a wrapper for a selected
group of DOM nodes
 $() function is a factory method that creates
JQuery objects
 $(“dt”) is a JQuery object containing all the “dt”
elements in the document
Continue…
 .addClass() method changes the
DOM nodes by adding a ‘class’
attribute
 The ‘class’ attribute is a special CSS
construct that provides a visual
architecture independent of the element
structures
 $(“dt”).addClass(“emphasize”) will
change all occurrences of <dt> to
<dt class=“emphasize”>
 See also .removeClass()
Continue…
 To make this change, put it in a
function and call it when the
document has been loaded and the
DOM is created
function doEmph(){$(“dt”).addClass(“emphasize”)}
<body onLoad=“doEmph()”>
 We had to alter the HTML (bad)
 Structure and appearance should be
separated!
 Also, onLoad waits until all images etc
are loaded. Tedious.
Continue…
 JQuery provides an independent
scheduling point after DOM is created
and before images are loaded
 $(document).ready(doEmph);
 No HTML mods required. All done in
script.
 Better solution:
 $(document).ready(function(){
$(“dt”).addClass(“emphasize”)
}); <html><head>
<script src="jquery.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
…
JQuery Selectors
 CSS
 p element name
 #id identifier
 .class classname
 p.class element with class
 p a anchor as any descendant of p
 p > a anchor direct child of p
Continue…
 XPath
/html/body//divpaths
a[@href] anchor with an href attr
div[ol] div with an ol inside
//a[@ref='nofollow'] any anchor with a specific value
for the ref attribute
JQuery Filters
 p:first first paragraph
 li:last last list item
 a:nth(3) fourth link
 a:eq(3) fourth link
 p:even or p:odd every other paragraph
 a:gt(3) or a:lt(4) every link after the 4th or up to the fourth
 a:contains(‘click’) links that contain the word click
Example
 JQuery uses chaining as follows
$(‘a:contains("ECS")’).
parent().
addClass("emphasize")
JQuery Events
 bind(eventname, function) method
 ‘click’
 ‘change’
 ‘resize’
 ‘ready’
 ‘mouseover’ & ‘mouseout’
 ‘live’ or ‘delegate’ or ‘on’
 ‘load’
 Etc…
 $(“a[@href]”).bind(‘click’,function(){
$(this).addClass(‘red’);});
Other JQuery Effects
 .css(‘property’, ‘value’)
 .css({‘prop1’:‘value1’,
‘prop2’:’value2’…})
E.g. .css(‘color’, ‘red’)
 .fadeIn(speed) or fadeOut(speed)
 .hide(speed) or .show(speed)
 Where speed is ‘slow’, ‘normal’ or ‘fast’
 Etc…
More JQuery Changes
DOM
 .attr({‘name’, ‘value’})
 sets a new attribute (or many)
 $(‘<i>hello</i>’)
 Creates a new element
 $(‘<i>hello</i>’).insertAfter(‘div.chapter p’);
 Creates element and inserts it into the document
 .html() or .text() or .empty() will replace
matched elements with newly created
elements
jQuery Sources
 Latest version 2.1.x
 jQuery Website https://jquery.com/download/
 Google Developers
https://ajax.googleapis.com/ajax/libs/jquery/2.1.
3/jquery.min.js
Thank you!

Contenu connexe

Tendances

J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
testingphase
 

Tendances (20)

jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Drupal.Behaviors
Drupal.BehaviorsDrupal.Behaviors
Drupal.Behaviors
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Javascript jQuery jQuery Ui
Javascript jQuery jQuery UiJavascript jQuery jQuery Ui
Javascript jQuery jQuery Ui
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 

En vedette (6)

webstudy jquery
webstudy jquerywebstudy jquery
webstudy jquery
 
JavaScript the Smart Way - Getting Started with jQuery
JavaScript the Smart Way - Getting Started with jQueryJavaScript the Smart Way - Getting Started with jQuery
JavaScript the Smart Way - Getting Started with jQuery
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Introductory css and j query
Introductory css and j queryIntroductory css and j query
Introductory css and j query
 
JQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the FutureJQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the Future
 
J query 17-visual-cheat-sheet
J query 17-visual-cheat-sheetJ query 17-visual-cheat-sheet
J query 17-visual-cheat-sheet
 

Similaire à jQuery Beginner

Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
guest5d87aa6
 

Similaire à jQuery Beginner (20)

jquery.ppt
jquery.pptjquery.ppt
jquery.ppt
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
 
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
 
J query training
J query trainingJ query training
J query training
 
Jquery
JqueryJquery
Jquery
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Jquery tutorial
Jquery tutorialJquery tutorial
Jquery tutorial
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And Tricks
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
jQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusionjQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusion
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
前端概述
前端概述前端概述
前端概述
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 

Plus de kumar gaurav

Plus de kumar gaurav (20)

Need Of Enterprise Integration
Need Of Enterprise IntegrationNeed Of Enterprise Integration
Need Of Enterprise Integration
 
Mulesoft file connector
Mulesoft file connectorMulesoft file connector
Mulesoft file connector
 
Mulesoft http connector
Mulesoft http connectorMulesoft http connector
Mulesoft http connector
 
Reason to connect with Mulesoft
Reason to connect with MulesoftReason to connect with Mulesoft
Reason to connect with Mulesoft
 
Mulesoft idempotent Message Filter
Mulesoft idempotent Message FilterMulesoft idempotent Message Filter
Mulesoft idempotent Message Filter
 
Mulesoft Using Groovy Component
Mulesoft Using Groovy ComponentMulesoft Using Groovy Component
Mulesoft Using Groovy Component
 
Mulesoft vm transport reference
Mulesoft vm transport referenceMulesoft vm transport reference
Mulesoft vm transport reference
 
Mulesoft Calling Flow of Other Applications
Mulesoft Calling Flow of Other ApplicationsMulesoft Calling Flow of Other Applications
Mulesoft Calling Flow of Other Applications
 
Mulesoft Solutions for Mobile
Mulesoft Solutions for MobileMulesoft Solutions for Mobile
Mulesoft Solutions for Mobile
 
Mulesoft Solutions for SOA
Mulesoft Solutions for SOAMulesoft Solutions for SOA
Mulesoft Solutions for SOA
 
Mulesoft Solutions for IoT
Mulesoft Solutions for IoTMulesoft Solutions for IoT
Mulesoft Solutions for IoT
 
Mulesoft Anypoint platform for APIs
Mulesoft Anypoint platform for APIsMulesoft Anypoint platform for APIs
Mulesoft Anypoint platform for APIs
 
Oracle Managed Files Transfer- Key based authentication
Oracle Managed Files Transfer- Key based authenticationOracle Managed Files Transfer- Key based authentication
Oracle Managed Files Transfer- Key based authentication
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Struggle that counts
Struggle that countsStruggle that counts
Struggle that counts
 
Team Work
Team WorkTeam Work
Team Work
 
MySQL index optimization techniques
MySQL index optimization techniquesMySQL index optimization techniques
MySQL index optimization techniques
 
Security guidelines for web development
Security guidelines for web developmentSecurity guidelines for web development
Security guidelines for web development
 
Java web services
Java web servicesJava web services
Java web services
 
Oracle web center suit
Oracle web center suitOracle web center suit
Oracle web center suit
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

jQuery Beginner

  • 2. JQuery  Powerful JavaScript library  Simplify common JavaScript tasks  Access parts of a page  using CSS or XPath-like expressions  Modify the appearance of a page  Alter the content of a page  Change the user’s interaction with a page  Add animation to a page  Provide AJAX support  Abstract away browser quirks
  • 3. Introductory Sample <html> <body> <h1>Cities of the World</h1> <dl> <dt>Paris</dt><dd>Chic, fashionable, expensive rude</dd> <dt>Sydney</dt><dd>Opera house but no culture, Mardi Gras, fireworks</dd> </dl> </body> </html> h1 {font-size: 2.5em; margin-bottom: 0;} .emphasize {font-style: italic; color:red;}
  • 4. Basic JQuery  Selecting part of document is fundamental operation  A JQuery object is a wrapper for a selected group of DOM nodes  $() function is a factory method that creates JQuery objects  $(“dt”) is a JQuery object containing all the “dt” elements in the document
  • 5. Continue…  .addClass() method changes the DOM nodes by adding a ‘class’ attribute  The ‘class’ attribute is a special CSS construct that provides a visual architecture independent of the element structures  $(“dt”).addClass(“emphasize”) will change all occurrences of <dt> to <dt class=“emphasize”>  See also .removeClass()
  • 6. Continue…  To make this change, put it in a function and call it when the document has been loaded and the DOM is created function doEmph(){$(“dt”).addClass(“emphasize”)} <body onLoad=“doEmph()”>  We had to alter the HTML (bad)  Structure and appearance should be separated!  Also, onLoad waits until all images etc are loaded. Tedious.
  • 7. Continue…  JQuery provides an independent scheduling point after DOM is created and before images are loaded  $(document).ready(doEmph);  No HTML mods required. All done in script.  Better solution:  $(document).ready(function(){ $(“dt”).addClass(“emphasize”) }); <html><head> <script src="jquery.js" type="text/javascript"></script> <script src="test.js" type="text/javascript"></script> …
  • 8. JQuery Selectors  CSS  p element name  #id identifier  .class classname  p.class element with class  p a anchor as any descendant of p  p > a anchor direct child of p
  • 9. Continue…  XPath /html/body//divpaths a[@href] anchor with an href attr div[ol] div with an ol inside //a[@ref='nofollow'] any anchor with a specific value for the ref attribute
  • 10. JQuery Filters  p:first first paragraph  li:last last list item  a:nth(3) fourth link  a:eq(3) fourth link  p:even or p:odd every other paragraph  a:gt(3) or a:lt(4) every link after the 4th or up to the fourth  a:contains(‘click’) links that contain the word click
  • 11. Example  JQuery uses chaining as follows $(‘a:contains("ECS")’). parent(). addClass("emphasize")
  • 12. JQuery Events  bind(eventname, function) method  ‘click’  ‘change’  ‘resize’  ‘ready’  ‘mouseover’ & ‘mouseout’  ‘live’ or ‘delegate’ or ‘on’  ‘load’  Etc…  $(“a[@href]”).bind(‘click’,function(){ $(this).addClass(‘red’);});
  • 13. Other JQuery Effects  .css(‘property’, ‘value’)  .css({‘prop1’:‘value1’, ‘prop2’:’value2’…}) E.g. .css(‘color’, ‘red’)  .fadeIn(speed) or fadeOut(speed)  .hide(speed) or .show(speed)  Where speed is ‘slow’, ‘normal’ or ‘fast’  Etc…
  • 14. More JQuery Changes DOM  .attr({‘name’, ‘value’})  sets a new attribute (or many)  $(‘<i>hello</i>’)  Creates a new element  $(‘<i>hello</i>’).insertAfter(‘div.chapter p’);  Creates element and inserts it into the document  .html() or .text() or .empty() will replace matched elements with newly created elements
  • 15. jQuery Sources  Latest version 2.1.x  jQuery Website https://jquery.com/download/  Google Developers https://ajax.googleapis.com/ajax/libs/jquery/2.1. 3/jquery.min.js