SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
jQueryWRITE LESS, DO MORE
1
INTRODUCTION
2
jQuery
 Open source Javascript framework
 Crossbrowser client side scripting
 Uses CSS syntax for selection
 Most used Javascript library
 $ - synonymous with the jQuery function
3
Loading jQuery
Locally : <script src="/js/jquery.js">
CDN :
 ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
 ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js
BEST PRACTICE :
When scripts are downloading they block everything else in almost
all browsers. Load scripts at the bottom of the page so they don't
interrupt page content downloads.
4
Ready state
 The DOM is "ready" when everything on the page has loaded.
 Stylesheets
 JavaScripts
 Images
 In order to make sure that jQuery can find all the elements, wrap the
jQuery code within in the document ready function.
$(document).ready(function(){ … });
$(function() { … });
5
Selecting elements
Selector Reference :
http://www.w3schools.com/jquery/jquery_ref_selectors.asp
 Pseudo selectors (:) - :first, :button, :input, :checked
 Filtering selectors – has, not, filter, eq
Testing Selectors :
http://www.w3schools.com/jquery/trysel.asp
CONVENTION :
When storing selections in a variable prefix ‘$’ to indicate that the variable
contains a jQuery object.
6
Getters and setters
 GET :
var htmlContent = $(“selector”).html()
var textContent = $(“selector”).text()
 SET :
$(“selector”).html(‘content’)
$(“selector”).text(‘content’)
 Example :
https://jsfiddle.net/NivedhithaV/aw9q87b5/2/
For form elements val() is used
7
Iteration
$( 'li' ).each(function( index, elem ) {
// this: the current DOM element
// index: the current element's index in the selection
// elem: the current DOM element (same as this)
$( elem ).prepend( '<b>' + index + ': </b>' );
});
Example :
https://jsfiddle.net/NivedhithaV/2shq5x69/1/
8
Chaining
CALLING A SERIES OF METHODS ON A SELECTION WITHOUT REPEATING
THE SELECTOR
9
TRAVERSING &
MANIPULATING THE
DOM
10
Selecting elements relative to
another element
 First
 Siblings
 Prev / next
 Parent
 Parents
 Children
 Find
 closest
11
Manipulating Style
 Indrirectly using classes
 addClass
 removeClass
 toggleClass
 Directly styling elements
 $(“selector”).css(“property”, “value”)
 $(“selector”).css({
“property”, “value”,
“property”, “value”…
})
12
EVENTS
13
Binding events
 Events –
 Click, dblclick, change, blur, focus
 Mouse events
 Keyboard events
 Bind/unbind – connecting/disconnecting event handler
 One – connecting events to run only once
 On – attaching one or more events, will work for current and future
elements
 Trigger – triggering an event after binding
14
Other functions
 preventDefault – prevents the default action of the event
$( "a" ).click(function( event ) {
event.preventDefault();
...
});
 stopPropogation – prevents event from bubbling up to parent
 Example : https://jsfiddle.net/NivedhithaV/32rvk8zk/1/
15
EFFECTS
16
Built-in effects
 Effects
 Show/hide
 fadeIn/fadeOut
 SlideUp/slideDown/slideToggle
 Duration
 Effect(duration in ms)
 Slow/fast
 Custom effects – animate()
17
AJAX
18
Asynchronous javascript and XML
 Loading data from server without page reload
 Uses Xmlhttprequest - XHR
 Returns jqXHR object — a jQuery XML HTTP Request
 Form serialize
 Example - https://jsfiddle.net/NivedhithaV/mhJRQ/9/
19
 $.ajax
$.ajax({
url: ‘/sample-url',
dataType: 'json',
success: function( data) {
//callback
},
error: function( req, status, err ) {
//error
}
});
20
 $.get – non destructive operations
$.get( ‘/sample-url', function( html ){
$( '#target' ).html( html );
});
 $.post – destructive operations
$.post( '/sample-url', { key: ‘value' },
function( data) {
console.log( data);
});
21
jqXHR
var data = $.ajax({
url: '/sample-url',
dataType: 'json'
});
 Then
 Done
 Fail
 Always
22
Questions?
23

Más contenido relacionado

La actualidad más candente

jQuery presentation
jQuery presentationjQuery presentation
jQuery presentationMahesh Reddy
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
 
WordPress Third Party Authentication
WordPress Third Party AuthenticationWordPress Third Party Authentication
WordPress Third Party AuthenticationAaron Brazell
 
jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');mikehostetler
 
Jquery for post a form
Jquery for post a formJquery for post a form
Jquery for post a formRakesh Kumar
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Eventsdmethvin
 
HTML5 - The 2012 of the Web
HTML5 - The 2012 of the WebHTML5 - The 2012 of the Web
HTML5 - The 2012 of the WebRobert Nyman
 
Casl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptxCasl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptxSergiy Stotskiy
 
Java script browser objects 2
Java script browser objects 2Java script browser objects 2
Java script browser objects 2H K
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive OverviewMohamed Loey
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to JqueryAmzad Hossain
 

La actualidad más candente (20)

jQuery presentation
jQuery presentationjQuery presentation
jQuery presentation
 
Owasp & php
Owasp & phpOwasp & php
Owasp & php
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
 
WordPress Third Party Authentication
WordPress Third Party AuthenticationWordPress Third Party Authentication
WordPress Third Party Authentication
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');jQuery('#knowledge').appendTo('#you');
jQuery('#knowledge').appendTo('#you');
 
Jquery for post a form
Jquery for post a formJquery for post a form
Jquery for post a form
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
 
NodeJS in Windows Azure
NodeJS in Windows AzureNodeJS in Windows Azure
NodeJS in Windows Azure
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
HTML5 - The 2012 of the Web
HTML5 - The 2012 of the WebHTML5 - The 2012 of the Web
HTML5 - The 2012 of the Web
 
YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU
 
OUTDATED (Encore)
OUTDATED (Encore)OUTDATED (Encore)
OUTDATED (Encore)
 
Canjs
CanjsCanjs
Canjs
 
Jquery Cheatsheet
Jquery CheatsheetJquery Cheatsheet
Jquery Cheatsheet
 
Casl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptxCasl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptx
 
Java script browser objects 2
Java script browser objects 2Java script browser objects 2
Java script browser objects 2
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive Overview
 
Jquery image slider
Jquery image slider Jquery image slider
Jquery image slider
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 

Destacado

Assurance and Performance Framework presentation
Assurance and Performance Framework presentationAssurance and Performance Framework presentation
Assurance and Performance Framework presentationMartin Gavet
 
Você se considera um profissional de alta produtividade?
Você se considera um profissional de alta produtividade?Você se considera um profissional de alta produtividade?
Você se considera um profissional de alta produtividade?Mariana de Góes Borges
 
Liberate-Strategy-2014-18-v.1
Liberate-Strategy-2014-18-v.1Liberate-Strategy-2014-18-v.1
Liberate-Strategy-2014-18-v.1Martin Gavet
 
Whyalla News -Experiencing the workforce
Whyalla News -Experiencing the workforceWhyalla News -Experiencing the workforce
Whyalla News -Experiencing the workforceBaerbel McDougall
 
Il come e il perchè
Il come e il perchèIl come e il perchè
Il come e il perchèBernardo1969
 
Wales German Network reference
Wales German Network referenceWales German Network reference
Wales German Network referenceStephen Parkinson
 
Prontos para mais uma transformação? Bem vindo ao mundo digital!
Prontos para mais uma transformação? Bem vindo ao mundo digital!Prontos para mais uma transformação? Bem vindo ao mundo digital!
Prontos para mais uma transformação? Bem vindo ao mundo digital!Mariana de Góes Borges
 
Brochure: Aurora Mobile
Brochure: Aurora MobileBrochure: Aurora Mobile
Brochure: Aurora MobileSue Niemiec
 
2 safety precautions
2 safety precautions2 safety precautions
2 safety precautionsmiamore07
 

Destacado (12)

Snm 9872346154
Snm 9872346154Snm 9872346154
Snm 9872346154
 
Assurance and Performance Framework presentation
Assurance and Performance Framework presentationAssurance and Performance Framework presentation
Assurance and Performance Framework presentation
 
Você se considera um profissional de alta produtividade?
Você se considera um profissional de alta produtividade?Você se considera um profissional de alta produtividade?
Você se considera um profissional de alta produtividade?
 
Liberate-Strategy-2014-18-v.1
Liberate-Strategy-2014-18-v.1Liberate-Strategy-2014-18-v.1
Liberate-Strategy-2014-18-v.1
 
Whyalla News -Experiencing the workforce
Whyalla News -Experiencing the workforceWhyalla News -Experiencing the workforce
Whyalla News -Experiencing the workforce
 
Il come e il perchè
Il come e il perchèIl come e il perchè
Il come e il perchè
 
Wales German Network reference
Wales German Network referenceWales German Network reference
Wales German Network reference
 
Introduction to HTML5 and CSS3
Introduction to HTML5 and CSS3Introduction to HTML5 and CSS3
Introduction to HTML5 and CSS3
 
Prontos para mais uma transformação? Bem vindo ao mundo digital!
Prontos para mais uma transformação? Bem vindo ao mundo digital!Prontos para mais uma transformação? Bem vindo ao mundo digital!
Prontos para mais uma transformação? Bem vindo ao mundo digital!
 
Brochure: Aurora Mobile
Brochure: Aurora MobileBrochure: Aurora Mobile
Brochure: Aurora Mobile
 
ccv
ccvccv
ccv
 
2 safety precautions
2 safety precautions2 safety precautions
2 safety precautions
 

Similar a Introduction to jQuery

Js Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterJs Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterIvo Andreev
 
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
 
JavaScript patterns chapter 8 of mine
JavaScript patterns chapter 8 of mineJavaScript patterns chapter 8 of mine
JavaScript patterns chapter 8 of mineChien-Wei Huang
 
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...Thinqloud
 
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
 
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
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
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
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQueryLaurence Svekis ✔
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQueryKnoldus Inc.
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 

Similar a Introduction to jQuery (20)

Js Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterJs Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform better
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
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
 
Web2 - jQuery
Web2 - jQueryWeb2 - jQuery
Web2 - jQuery
 
JavaScript patterns chapter 8 of mine
JavaScript patterns chapter 8 of mineJavaScript patterns chapter 8 of mine
JavaScript patterns chapter 8 of mine
 
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...
 
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
 
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
 
J query training
J query trainingJ query training
J query training
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Digesting jQuery
Digesting jQueryDigesting jQuery
Digesting jQuery
 
Lec 5
Lec 5Lec 5
Lec 5
 
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
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
DrupalCon jQuery
DrupalCon jQueryDrupalCon jQuery
DrupalCon jQuery
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
jQueryUI
 jQueryUI jQueryUI
jQueryUI
 

Último

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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 WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Introduction to jQuery

  • 3. jQuery  Open source Javascript framework  Crossbrowser client side scripting  Uses CSS syntax for selection  Most used Javascript library  $ - synonymous with the jQuery function 3
  • 4. Loading jQuery Locally : <script src="/js/jquery.js"> CDN :  ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js  ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js BEST PRACTICE : When scripts are downloading they block everything else in almost all browsers. Load scripts at the bottom of the page so they don't interrupt page content downloads. 4
  • 5. Ready state  The DOM is "ready" when everything on the page has loaded.  Stylesheets  JavaScripts  Images  In order to make sure that jQuery can find all the elements, wrap the jQuery code within in the document ready function. $(document).ready(function(){ … }); $(function() { … }); 5
  • 6. Selecting elements Selector Reference : http://www.w3schools.com/jquery/jquery_ref_selectors.asp  Pseudo selectors (:) - :first, :button, :input, :checked  Filtering selectors – has, not, filter, eq Testing Selectors : http://www.w3schools.com/jquery/trysel.asp CONVENTION : When storing selections in a variable prefix ‘$’ to indicate that the variable contains a jQuery object. 6
  • 7. Getters and setters  GET : var htmlContent = $(“selector”).html() var textContent = $(“selector”).text()  SET : $(“selector”).html(‘content’) $(“selector”).text(‘content’)  Example : https://jsfiddle.net/NivedhithaV/aw9q87b5/2/ For form elements val() is used 7
  • 8. Iteration $( 'li' ).each(function( index, elem ) { // this: the current DOM element // index: the current element's index in the selection // elem: the current DOM element (same as this) $( elem ).prepend( '<b>' + index + ': </b>' ); }); Example : https://jsfiddle.net/NivedhithaV/2shq5x69/1/ 8
  • 9. Chaining CALLING A SERIES OF METHODS ON A SELECTION WITHOUT REPEATING THE SELECTOR 9
  • 11. Selecting elements relative to another element  First  Siblings  Prev / next  Parent  Parents  Children  Find  closest 11
  • 12. Manipulating Style  Indrirectly using classes  addClass  removeClass  toggleClass  Directly styling elements  $(“selector”).css(“property”, “value”)  $(“selector”).css({ “property”, “value”, “property”, “value”… }) 12
  • 14. Binding events  Events –  Click, dblclick, change, blur, focus  Mouse events  Keyboard events  Bind/unbind – connecting/disconnecting event handler  One – connecting events to run only once  On – attaching one or more events, will work for current and future elements  Trigger – triggering an event after binding 14
  • 15. Other functions  preventDefault – prevents the default action of the event $( "a" ).click(function( event ) { event.preventDefault(); ... });  stopPropogation – prevents event from bubbling up to parent  Example : https://jsfiddle.net/NivedhithaV/32rvk8zk/1/ 15
  • 17. Built-in effects  Effects  Show/hide  fadeIn/fadeOut  SlideUp/slideDown/slideToggle  Duration  Effect(duration in ms)  Slow/fast  Custom effects – animate() 17
  • 19. Asynchronous javascript and XML  Loading data from server without page reload  Uses Xmlhttprequest - XHR  Returns jqXHR object — a jQuery XML HTTP Request  Form serialize  Example - https://jsfiddle.net/NivedhithaV/mhJRQ/9/ 19
  • 20.  $.ajax $.ajax({ url: ‘/sample-url', dataType: 'json', success: function( data) { //callback }, error: function( req, status, err ) { //error } }); 20
  • 21.  $.get – non destructive operations $.get( ‘/sample-url', function( html ){ $( '#target' ).html( html ); });  $.post – destructive operations $.post( '/sample-url', { key: ‘value' }, function( data) { console.log( data); }); 21
  • 22. jqXHR var data = $.ajax({ url: '/sample-url', dataType: 'json' });  Then  Done  Fail  Always 22