ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
jQueryJon Erickson@jonericksonhttp://jonerickson.me/http://jonerickson.me/jquery/
What is jQuery?JavaScript framework that makes your life easierSelectors & ChainingDOM TraversingDOM ManipulationEvent HandlingAnimations/EffectsAJAXBuilt-in UtilitiesExtensibleTons of plug-ins built by the community for our use
Why jQuery?I¡¯m not an expert at JavaScriptThe people who created jQuery are!Do not need to worry about cross-browser issues (all abstracted)Light Weight (19 kb compressed)DRY ¨C Simple plug-in model allows for code reuseAnimations/Effects are simpleCommunity support is growing rapidlyMicrosoft adoption (included in MVC template)Tutorials, plug-ins, etc.Client-side scripting is fun with jQuery and breathes some new life into your applicationsFocus more on the code that solves your problemAmazon, BBC, Dell, Google, IBM, NBC, Netflix, Twitter
Sample jQueryOur DOMInclude jQueryThe ¡®ready event¡¯ ¨C Binds a function to be executed whenever the DOM is readySelect the ¡®toggleContent¡¯ DOM element and bind a click event handler to it.Select the ¡®content¡¯ DOM element and set the text to ¡®Hello World!¡¯Prevent the default behavior of the anchor tag by returning false
Dollar Function $();JavaScript identifiers can start with $The jQuery framework automatically assigns ¡®$¡¯ to the ¡®jQuery¡¯ function$ === jQuerytrue$(selector) is same as jQuery(selector)Can use utility function to unassign $$.noConflict();$ === jQuery;	falseCan reassign jQuery to another variable$j = $.noConflict();	$j === jQuery;	true$j === $;		false$ === jQuery;	false
Document Ready Event$(document).ready(fn);The bound function will be called the instant the DOM is ready to be read and manipulated.As many as you want on the page.Executed in the order they were added.There is a shortcut: $(fn);
SelectorsCSS3 Selectors
Filters$(¡®div:empty¡¯), $(¡®:empty¡¯), $(¡®div:not(:empty)¡¯)Custom Filter Used
ChainingMost jQuery methods return another jQuery object (usually the same collection), which means you can chain method calls together with a fluent like syntaxSome methods that stop a chain, these methods return a value from the jQuery object	.css(name), .text(), .html(), .val(), .height(), .width(), .is(¡®:visible¡¯)Some methods will return a different jQuery collection, you can revert to the previous collection by calling .end();
Attributes & ClassesGetters & Setters for attr, html, text, valGetter (returns String ¨C breaks chain)var text = $(¡®#myDiv¡¯).text();Setter (returns jQuery)$(¡®#myDiv¡¯).text(¡®Hello World!¡¯);text() escapes html()val() used with inputsattr() can take JSONAdd, Remove for Attributes & Classes.removeAttr(¡®someAttr¡¯);.addClass(¡®someClass¡¯);.removeClass(¡®someClass¡¯);.toggleClass(¡®someClass¡¯);
TraversingFamilyparent, parents, siblings, childrenProximityclosest, next, prev, nextAll, prevAllSearchingfind
Events.bind(type, data, fn)Binds a handler to an event on all matched elements.one(type, data, fn)Binds a handler to be executed only once for each matched element.trigger(event, data)Trigger an event to occur on all matched elements.unbind(type, fn)Removes event handlers from all matched elements.live(type, fn)Binds a handler to an event on all currently matched and future matched elements..die(type, fn)Removes a bound live event..hover(fnOver, fnOut)Interaction helper that will handle mouseover and mouseout.toggle(fn1, fn2, fn3, fnN, ¡­)Interaction helper that will toggle among two or more function calls every other click.Event Helpers	blur, change, click, dblclick, error, focus, keydown, keypress, keyup, load, mousedown, mouseenter, mouseleave, mousemove, mouseup, resize, scroll, select, submit, unload
ManipulationInserting Insideappend, prependappendTo, prependToInserting Outsideafter, beforeinsertAfter, insertBeforeInserting AroundwrapInnerwrapwrapAllReplacingreplaceWith, replaceAllRemovingempty, removeCopyingclone
EffectsBasicsshow, hide, toggleSlidingslideUp, slideDown, slideToggleFadingfadeIn, fadeOut, fadeTo (opacity 0-1)Customanimate, stop
Plug-insExtremely Simple ¨C Promotes code reuse and DRY principle$.fn.MyPlugin = function(params) {};Return a jQuery object to prevent from ¡°breaking the chain¡±Unless you are returning a specific valueBest Practice is to wrap the plug-in declaration within an anonymous JavaScript function in order to prevent collisions with the use of $Within the plug-in ¡®this¡¯ refers to the jQuery object
AJAXHelpersload, get, getJSON, getScript, post (all use $.ajax behind the scenes)$.ajaxSetup(options) can be used to globally set the default options for all AJAX request. You can still override these within each AJAX request object.Local Events ¨C subscribed to within AJAX request objectGlobal Events ¨C broadcast to all elements in the DOMCan be disabled within the AJAX request object¡¯s ¡®global¡¯ property.bind(¡®ajaxStart¡¯, fn) or .ajaxStart(fn)G | ajaxStartL | beforeSendG | ajaxSendL | successG | ajaxSuccessL | errorG | ajaxErrorL | completeG | ajaxCompleteG | ajaxStop
Utility FunctionsArray and Object Operations$.each(object, callback) ¨C Callback function will run for each item in the object. The each method is meant to be an immutable iterator and returns the original array.$.map(array, callback) ¨C Callback function will run for each item in the array. The map method can be used as an iterator, but is designed to be used for manipulation of the supplied array and returns a new array.$.merge(first, second) ¨C Merges the second array into the first array.$.unique(array) ¨C Removes duplicate elements (only works on arrays of DOM elements).$.extend(object) ¨C Add functions into the jQuery namespace.$.extend(deep, target, object1, objectN) ¨C Merge values from objects 1 to N into target object. Deep is an optional boolean that if true, tells jQuery to do a deep copy.$.grep(array, callback, invert) ¨C Iterates through array, and returns a new array with values from the original array that satisfy the criteria specified in the callback.$.inArray(value, array) ¨C Gets the index of the value in the array (-1 if not found).String Operations$.trim(str) ¨C Removes whitespace from the given string.Test Operations$.isArray(obj) ¨C Determines if the object is an array.$.isFunction(obj) ¨C Determines if the object is a function.
jQuery DataCan store data on one or more jQuery elements.data(name, value)value is an objectRetrieves data from the first element in the jQuery object.data(name)
ResourcesjQuery Mainhttp://jquery.comhttp://docs.jquery.com/Downloading_jQueryjQuery API Documentationhttp://api.jquery.comhttp://docs.jquery.comjQuery UIhttp://jqueryui.comhttp://jqueryui.com/themeroller/jQuery Bloghttp://blog.jquery.com/Around The Webhttp://stackoverflow.comhttp://www.nettuts.comhttp://www.smashingmagazine.comToolsVisual Studio JavaScript Intellisense Support (KB958502)http://getfirebug.com/ (Firebug Firefox Plug-in)http://jsbin.com/  (JS Bin - Collaborative JavaScript Debugging)Twitter@jquery, @jqueryui, @jresig, @rem, @codylindley , @reybango, @elijahmanor, @jamespadolsey, @brandonaaron, @malsup, @pbakaus, @rworth
jQuery

More Related Content

What's hot (9)

JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and Lodash
Bret Little
?
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
Nicolas Carlo
?
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
sotlsoc
?
Wicket KT part 2
Wicket KT part 2Wicket KT part 2
Wicket KT part 2
stuq
?
Scala in practice
Scala in practiceScala in practice
Scala in practice
andyrobinson8
?
Introduction to-scala
Introduction to-scalaIntroduction to-scala
Introduction to-scala
Hamid Jafarian
?
jQuery 1.7 visual cheat sheet
jQuery 1.7 visual cheat sheetjQuery 1.7 visual cheat sheet
jQuery 1.7 visual cheat sheet
Jiby John
?
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bon¨¦r
?
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
bpstudy
?
JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and Lodash
Bret Little
?
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
Nicolas Carlo
?
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
sotlsoc
?
Wicket KT part 2
Wicket KT part 2Wicket KT part 2
Wicket KT part 2
stuq
?
jQuery 1.7 visual cheat sheet
jQuery 1.7 visual cheat sheetjQuery 1.7 visual cheat sheet
jQuery 1.7 visual cheat sheet
Jiby John
?
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bon¨¦r
?
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
¥Ï¥¤¥Ö¥ê¥Ã¥ÉÑÔÓﳧ³¦²¹±ô²¹¤òʹ¤¦
bpstudy
?

Viewers also liked (6)

Kaleehume 3222
Kaleehume 3222Kaleehume 3222
Kaleehume 3222
Ann Witherspoon
?
Sawwan desire 1_3
Sawwan desire 1_3Sawwan desire 1_3
Sawwan desire 1_3
Ann Witherspoon
?
Sawwan desire 1-3
Sawwan desire 1-3Sawwan desire 1-3
Sawwan desire 1-3
Ann Witherspoon
?
Mueller n 1_22_2-1
Mueller n 1_22_2-1Mueller n 1_22_2-1
Mueller n 1_22_2-1
Ann Witherspoon
?

Similar to jQuery (20)

jQuery
jQueryjQuery
jQuery
Jay Poojara
?
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
?
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 New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New Evolution
Allan Huang
?
jQuery
jQueryjQuery
jQuery
Ivano Malavolta
?
jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
Allegient
?
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
azz71
?
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
?
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptxMicrosoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
tutorialsruby
?
jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
guestcf600a
?
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" /><img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
tutorialsruby
?
jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
guestcf600a
?
droidparts
droidpartsdroidparts
droidparts
Droidcon Berlin
?
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
?
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
?
J query training
J query trainingJ query training
J query training
FIS - Fidelity Information Services
?
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
?
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Nagaraju Sangam
?
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
?
Ruby tricks2
Ruby tricks2Ruby tricks2
Ruby tricks2
Micha? ?omnicki
?
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
?
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 New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New Evolution
Allan Huang
?
jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
Allegient
?
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
azz71
?
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
?
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptxMicrosoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
Microsoft PowerPoint - <b>jQuery</b>-1-Ajax.pptx
tutorialsruby
?
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" /><img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
<img src=/slideshow/jquery-2372783/2372783/"../i/r_14.png" />
tutorialsruby
?
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
?
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
?
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
?
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
?

Recently uploaded (20)

APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
?
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
DianaGray10
?
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
?
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AIGDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
James Anderson
?
ScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 EdinburghScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 Edinburgh
Ray Bugg
?
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc¨ªa Lavilla
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Solana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdfSolana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdf
Lisa ward
?
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio WebUiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
DianaGray10
?
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
David Brossard
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
DianaGray10
?
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
?
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
?
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
DianaGray10
?
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
?
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AIGDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
GDG Cloud Southlake #41: Shay Levi: Beyond the Hype:How Enterprises Are Using AI
James Anderson
?
ScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 EdinburghScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 Edinburgh
Ray Bugg
?
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
Solana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdfSolana Developer Hiring for Enterprises Key Considerations.pdf
Solana Developer Hiring for Enterprises Key Considerations.pdf
Lisa ward
?
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio WebUiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
UiPath NY AI Series: Session 4: UiPath AutoPilot for Developers using Studio Web
DianaGray10
?
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
David Brossard
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
SAP Automation with UiPath: SAP Test Automation - Part 5 of 8
DianaGray10
?
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
?

jQuery

  • 2. What is jQuery?JavaScript framework that makes your life easierSelectors & ChainingDOM TraversingDOM ManipulationEvent HandlingAnimations/EffectsAJAXBuilt-in UtilitiesExtensibleTons of plug-ins built by the community for our use
  • 3. Why jQuery?I¡¯m not an expert at JavaScriptThe people who created jQuery are!Do not need to worry about cross-browser issues (all abstracted)Light Weight (19 kb compressed)DRY ¨C Simple plug-in model allows for code reuseAnimations/Effects are simpleCommunity support is growing rapidlyMicrosoft adoption (included in MVC template)Tutorials, plug-ins, etc.Client-side scripting is fun with jQuery and breathes some new life into your applicationsFocus more on the code that solves your problemAmazon, BBC, Dell, Google, IBM, NBC, Netflix, Twitter
  • 4. Sample jQueryOur DOMInclude jQueryThe ¡®ready event¡¯ ¨C Binds a function to be executed whenever the DOM is readySelect the ¡®toggleContent¡¯ DOM element and bind a click event handler to it.Select the ¡®content¡¯ DOM element and set the text to ¡®Hello World!¡¯Prevent the default behavior of the anchor tag by returning false
  • 5. Dollar Function $();JavaScript identifiers can start with $The jQuery framework automatically assigns ¡®$¡¯ to the ¡®jQuery¡¯ function$ === jQuerytrue$(selector) is same as jQuery(selector)Can use utility function to unassign $$.noConflict();$ === jQuery; falseCan reassign jQuery to another variable$j = $.noConflict(); $j === jQuery; true$j === $; false$ === jQuery; false
  • 6. Document Ready Event$(document).ready(fn);The bound function will be called the instant the DOM is ready to be read and manipulated.As many as you want on the page.Executed in the order they were added.There is a shortcut: $(fn);
  • 9. ChainingMost jQuery methods return another jQuery object (usually the same collection), which means you can chain method calls together with a fluent like syntaxSome methods that stop a chain, these methods return a value from the jQuery object .css(name), .text(), .html(), .val(), .height(), .width(), .is(¡®:visible¡¯)Some methods will return a different jQuery collection, you can revert to the previous collection by calling .end();
  • 10. Attributes & ClassesGetters & Setters for attr, html, text, valGetter (returns String ¨C breaks chain)var text = $(¡®#myDiv¡¯).text();Setter (returns jQuery)$(¡®#myDiv¡¯).text(¡®Hello World!¡¯);text() escapes html()val() used with inputsattr() can take JSONAdd, Remove for Attributes & Classes.removeAttr(¡®someAttr¡¯);.addClass(¡®someClass¡¯);.removeClass(¡®someClass¡¯);.toggleClass(¡®someClass¡¯);
  • 11. TraversingFamilyparent, parents, siblings, childrenProximityclosest, next, prev, nextAll, prevAllSearchingfind
  • 12. Events.bind(type, data, fn)Binds a handler to an event on all matched elements.one(type, data, fn)Binds a handler to be executed only once for each matched element.trigger(event, data)Trigger an event to occur on all matched elements.unbind(type, fn)Removes event handlers from all matched elements.live(type, fn)Binds a handler to an event on all currently matched and future matched elements..die(type, fn)Removes a bound live event..hover(fnOver, fnOut)Interaction helper that will handle mouseover and mouseout.toggle(fn1, fn2, fn3, fnN, ¡­)Interaction helper that will toggle among two or more function calls every other click.Event Helpers blur, change, click, dblclick, error, focus, keydown, keypress, keyup, load, mousedown, mouseenter, mouseleave, mousemove, mouseup, resize, scroll, select, submit, unload
  • 13. ManipulationInserting Insideappend, prependappendTo, prependToInserting Outsideafter, beforeinsertAfter, insertBeforeInserting AroundwrapInnerwrapwrapAllReplacingreplaceWith, replaceAllRemovingempty, removeCopyingclone
  • 14. EffectsBasicsshow, hide, toggleSlidingslideUp, slideDown, slideToggleFadingfadeIn, fadeOut, fadeTo (opacity 0-1)Customanimate, stop
  • 15. Plug-insExtremely Simple ¨C Promotes code reuse and DRY principle$.fn.MyPlugin = function(params) {};Return a jQuery object to prevent from ¡°breaking the chain¡±Unless you are returning a specific valueBest Practice is to wrap the plug-in declaration within an anonymous JavaScript function in order to prevent collisions with the use of $Within the plug-in ¡®this¡¯ refers to the jQuery object
  • 16. AJAXHelpersload, get, getJSON, getScript, post (all use $.ajax behind the scenes)$.ajaxSetup(options) can be used to globally set the default options for all AJAX request. You can still override these within each AJAX request object.Local Events ¨C subscribed to within AJAX request objectGlobal Events ¨C broadcast to all elements in the DOMCan be disabled within the AJAX request object¡¯s ¡®global¡¯ property.bind(¡®ajaxStart¡¯, fn) or .ajaxStart(fn)G | ajaxStartL | beforeSendG | ajaxSendL | successG | ajaxSuccessL | errorG | ajaxErrorL | completeG | ajaxCompleteG | ajaxStop
  • 17. Utility FunctionsArray and Object Operations$.each(object, callback) ¨C Callback function will run for each item in the object. The each method is meant to be an immutable iterator and returns the original array.$.map(array, callback) ¨C Callback function will run for each item in the array. The map method can be used as an iterator, but is designed to be used for manipulation of the supplied array and returns a new array.$.merge(first, second) ¨C Merges the second array into the first array.$.unique(array) ¨C Removes duplicate elements (only works on arrays of DOM elements).$.extend(object) ¨C Add functions into the jQuery namespace.$.extend(deep, target, object1, objectN) ¨C Merge values from objects 1 to N into target object. Deep is an optional boolean that if true, tells jQuery to do a deep copy.$.grep(array, callback, invert) ¨C Iterates through array, and returns a new array with values from the original array that satisfy the criteria specified in the callback.$.inArray(value, array) ¨C Gets the index of the value in the array (-1 if not found).String Operations$.trim(str) ¨C Removes whitespace from the given string.Test Operations$.isArray(obj) ¨C Determines if the object is an array.$.isFunction(obj) ¨C Determines if the object is a function.
  • 18. jQuery DataCan store data on one or more jQuery elements.data(name, value)value is an objectRetrieves data from the first element in the jQuery object.data(name)
  • 19. ResourcesjQuery Mainhttp://jquery.comhttp://docs.jquery.com/Downloading_jQueryjQuery API Documentationhttp://api.jquery.comhttp://docs.jquery.comjQuery UIhttp://jqueryui.comhttp://jqueryui.com/themeroller/jQuery Bloghttp://blog.jquery.com/Around The Webhttp://stackoverflow.comhttp://www.nettuts.comhttp://www.smashingmagazine.comToolsVisual Studio JavaScript Intellisense Support (KB958502)http://getfirebug.com/ (Firebug Firefox Plug-in)http://jsbin.com/ (JS Bin - Collaborative JavaScript Debugging)Twitter@jquery, @jqueryui, @jresig, @rem, @codylindley , @reybango, @elijahmanor, @jamespadolsey, @brandonaaron, @malsup, @pbakaus, @rworth

Editor's Notes