SlideShare a Scribd company logo
for Linux Lovers
Introduction Ralph Whitbeck jQuery Team Member, on the Developer Relations team Co-authored O’Rielly’s “jQuery Cookbook”  Senior Web Application Engineer  BrandLogic Corporation   ( http://brandlogic.com)  Blog: http://ralphwhitbeck.com Twitter: @RedWolves
The Official jQuery Podcast
Overview Who, what, where and why of jQuery Review Core jQuery Concepts jQuery API Overview jQuery plugins jQuery UI
Who uses jQuery  39.25% of all sites that use JavaScript About 30% of the top 10,000 sites http://trends.builtwith.com/javascript/JQuery
Who uses jQuery  39.25% of all sites that use JavaScript About 30% of the top 10,000 sites http://trends.builtwith.com/javascript/JQuery
What is jQuery?  jQuery is a JavaScript Library! Dealing with the DOM (e.g. selecting, creating, traversing, changing, etc.) JavaScript Events Animations Ajax interactions
What does that mean?
if (browserType == "ie")  document.poppedLayer =  eval('document.getElementById("HiddenDIV")');  else  document.poppedLayer =  eval('document.layers["HiddenDIV"]');  document.poppedLayer.style.visibility = "visible";  It means no more of this…
Using jQuery we can do this   jQuery(“#HiddenDiv”).show();
Using jQuery we can do this   jQuery (“#HiddenDIV”).show(); var $ = jQuery; $(“#HiddenDiv”).show(); jQuery function
Using jQuery we can do this   jQuery(“ #HiddenDIV ”).show(); jQuery Function jQuery Selector (CSS expression)
Using jQuery we can do this   jQuery(“#HiddenDIV”) .show(); jQuery Wrapped Set jQuery Function jQuery Selector (CSS expression)
Using jQuery we can do this   jQuery(“#HiddenDIV”). show() ; jQuery Wrapped Set jQuery Function jQuery Selector (CSS expression) jQuery Method
jQuery really is the “write less, do more” JavaScript Library!
Why use jQuery?  Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile  It’s for both developers and designers
Why use jQuery?  Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile It’s for both developers and designers
Why use jQuery?  Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile It’s for both developers and designers
Where to get jQuery Download the source from Github Or use a CDN jQuery CDN (Edgecast via  (mt) http://code.jquery.com/jquery-1.4.2.min.js  Minified version  http://code.jquery.com/jquery-1.4.2.js  Source version  Google Microsoft
Core jQuery Concepts Select Something, do something Create something, do something Chaining and Operating Demo’d  http://ejohn.org/apps/learn-jquery/ and http://ralphwhitbeck.com/talks/stackoverflowdevdays/createdosomething.html
jQuery API Overview Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities You can review Core Methods at: http://api.jquery.com
jQuery Plugins   There are over 2200 plugins  Plugins extend jQuery’s functionality If you can’t find the functionality in a plugin, make your own! You can make a jQuery Plugin in six steps
Step 1. create a private scope for $ alias <!DOCTYPE html><html><body> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ })(jQuery); </script></body></html> A jQuery plugin in 6 steps
Step 2. attach plugin to fn alias <!DOCTYPE html><html><body> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){ $(this).text($(this).text().replace(/hate/g,'love'));  };  })(jQuery); </script></body></html> A jQuery plugin in 6 steps
Step 2. attach plugin to fn alias <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){ $(this).text($(this).text().replace(/hate/g,'love'));  };  })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
Step 3. add implicit iteration <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love'));  });  };  })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
Step 3. add implicit iteration <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love'));  });  };  })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
Step 4. enable chaining <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  return  this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love'));  });  };  })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
Step 4. enable chaining <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  return this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love'));  });  };  })(jQuery); jQuery('p').loveNotHate() .hide() ; </script></body></html> A jQuery plugin in 6 steps
Step 5. add default options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text ));  });  };  $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function(){  return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text));  });  };  $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function( customOptions ){  return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text));  });  };  $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function( customOptions ){  var options = $.extend({},$.fn.loveNotHate.defaultOptions, customOptions);  return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text));  });  };  $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){  $.fn.loveNotHate = function( customOptions ){  var options = $.extend({},$.fn.loveNotHate.defaultOptions, customOptions);  return this.each(function(){ $(this).text($(this).text().replace(/hate/g, options.text ));  });  };  $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
Plugins are simple, just follow the steps!
jQuery UI   Official jQuery Project Provides plugins that make user interface elements easy Contains: Interactions  Widgets  Effects   Theming

More Related Content

PPT
Intro to jQuery
PPT
jQuery For Developers Stack Overflow Dev Days Toronto
KEY
SproutCore is Awesome - HTML5 Summer DevFest
PPT
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
PDF
Jquery tutorial
PPTX
Intro to jQuery
PPT
Wookie Meetup
PDF
Future of Web Development
Intro to jQuery
jQuery For Developers Stack Overflow Dev Days Toronto
SproutCore is Awesome - HTML5 Summer DevFest
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jquery tutorial
Intro to jQuery
Wookie Meetup
Future of Web Development

What's hot (20)

ZIP
Unit Tests Aren't Enough
PPTX
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
PPTX
Introduction to Jquery
ODP
Beginning WordPress Plugin Development
PDF
State of jQuery '08
PDF
JavaScript Like It’s 2013
PPTX
JSConf US 2010
PPTX
J Query - Your First Steps
KEY
Sizzle jQCon San Francisco 2012
PPT
Fast Loading JavaScript
PDF
Liferay + Wearables
PDF
The Art of Angular in 2016 - Devoxx UK 2016
PDF
Plugging into plugins
PDF
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
PDF
jQuery Proven Performance Tips & Tricks
PDF
The Developer Experience
PDF
The Art of Angular in 2016 - Devoxx France 2016
PDF
A tech writer, a map, and an app
PDF
Webdriver cheatsheets summary
PPT
YUI for your Hacks-IITB
Unit Tests Aren't Enough
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Introduction to Jquery
Beginning WordPress Plugin Development
State of jQuery '08
JavaScript Like It’s 2013
JSConf US 2010
J Query - Your First Steps
Sizzle jQCon San Francisco 2012
Fast Loading JavaScript
Liferay + Wearables
The Art of Angular in 2016 - Devoxx UK 2016
Plugging into plugins
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
jQuery Proven Performance Tips & Tricks
The Developer Experience
The Art of Angular in 2016 - Devoxx France 2016
A tech writer, a map, and an app
Webdriver cheatsheets summary
YUI for your Hacks-IITB
Ad

Viewers also liked (20)

DOC
Kt thn 4
PPTX
The Sorting Machine Web Quest Rubric
PPTX
Chris Woolard, Ofcom, Preparing for change – what will drive future growth?
DOCX
PPTX
Print ad porto
PDF
Mekanisme Evolusi 1 A ( Ch 22)
PDF
Unknown Unicast Storm Control in Internet Exchange
PDF
Replik tergugat-i-done
PPTX
Presentation biologi
PDF
Promoting your business flyer
PPT
From GNETS to Home School
PPTX
La perdurabilidad en las empresas familiares maria perez
PPTX
Presentation islam
PPTX
Presentation kaka
PPT
Derechos de autor entrega
DOCX
Tec16grupo9 ide9610177 anexos1
PDF
Sistemas visuais do cotidiano - Etec
PPTX
Ambient project in eksis komunika
KEY
Testing Your Sproutcore Presentation
Kt thn 4
The Sorting Machine Web Quest Rubric
Chris Woolard, Ofcom, Preparing for change – what will drive future growth?
Print ad porto
Mekanisme Evolusi 1 A ( Ch 22)
Unknown Unicast Storm Control in Internet Exchange
Replik tergugat-i-done
Presentation biologi
Promoting your business flyer
From GNETS to Home School
La perdurabilidad en las empresas familiares maria perez
Presentation islam
Presentation kaka
Derechos de autor entrega
Tec16grupo9 ide9610177 anexos1
Sistemas visuais do cotidiano - Etec
Ambient project in eksis komunika
Testing Your Sproutcore Presentation
Ad

Similar to Intro to jQuery - LUGOR - Part 1 (20)

PPT
jQuery and_drupal
PPTX
J Query Presentation
PPT
PPT
jQuery For Beginners - jQuery Conference 2009
PPT
Building Web Hack Interfaces
PPT
Eugene Andruszczenko: jQuery
PPT
jQuery Presentation - Refresh Events
PPT
jQuery Fundamentals
PPT
Rey Bango - HTML5: polyfills and shims
PPTX
PPT
Web App Testing With Selenium
PPT
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
PPT
jQuery Tips Tricks Trivia
PPTX
Extend sdk
PPT
Jquery
ODP
ActiveWeb: Chicago Java User Group Presentation
PPT
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
PPTX
jQuery for web development
KEY
Taking your Web App for a walk
PDF
Write Less Do More
jQuery and_drupal
J Query Presentation
jQuery For Beginners - jQuery Conference 2009
Building Web Hack Interfaces
Eugene Andruszczenko: jQuery
jQuery Presentation - Refresh Events
jQuery Fundamentals
Rey Bango - HTML5: polyfills and shims
Web App Testing With Selenium
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
jQuery Tips Tricks Trivia
Extend sdk
Jquery
ActiveWeb: Chicago Java User Group Presentation
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
jQuery for web development
Taking your Web App for a walk
Write Less Do More

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Machine Learning_overview_presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
sap open course for s4hana steps from ECC to s4
Per capita expenditure prediction using model stacking based on satellite ima...
MYSQL Presentation for SQL database connectivity
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Machine Learning_overview_presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
Chapter 3 Spatial Domain Image Processing.pdf
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing

Intro to jQuery - LUGOR - Part 1

  • 2. Introduction Ralph Whitbeck jQuery Team Member, on the Developer Relations team Co-authored O’Rielly’s “jQuery Cookbook” Senior Web Application Engineer  BrandLogic Corporation ( http://brandlogic.com) Blog: http://ralphwhitbeck.com Twitter: @RedWolves
  • 4. Overview Who, what, where and why of jQuery Review Core jQuery Concepts jQuery API Overview jQuery plugins jQuery UI
  • 5. Who uses jQuery 39.25% of all sites that use JavaScript About 30% of the top 10,000 sites http://trends.builtwith.com/javascript/JQuery
  • 6. Who uses jQuery 39.25% of all sites that use JavaScript About 30% of the top 10,000 sites http://trends.builtwith.com/javascript/JQuery
  • 7. What is jQuery? jQuery is a JavaScript Library! Dealing with the DOM (e.g. selecting, creating, traversing, changing, etc.) JavaScript Events Animations Ajax interactions
  • 9. if (browserType == &quot;ie&quot;) document.poppedLayer = eval('document.getElementById(&quot;HiddenDIV&quot;)'); else document.poppedLayer = eval('document.layers[&quot;HiddenDIV&quot;]'); document.poppedLayer.style.visibility = &quot;visible&quot;; It means no more of this…
  • 10. Using jQuery we can do this   jQuery(“#HiddenDiv”).show();
  • 11. Using jQuery we can do this   jQuery (“#HiddenDIV”).show(); var $ = jQuery; $(“#HiddenDiv”).show(); jQuery function
  • 12. Using jQuery we can do this   jQuery(“ #HiddenDIV ”).show(); jQuery Function jQuery Selector (CSS expression)
  • 13. Using jQuery we can do this   jQuery(“#HiddenDIV”) .show(); jQuery Wrapped Set jQuery Function jQuery Selector (CSS expression)
  • 14. Using jQuery we can do this   jQuery(“#HiddenDIV”). show() ; jQuery Wrapped Set jQuery Function jQuery Selector (CSS expression) jQuery Method
  • 15. jQuery really is the “write less, do more” JavaScript Library!
  • 16. Why use jQuery? Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile It’s for both developers and designers
  • 17. Why use jQuery? Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile It’s for both developers and designers
  • 18. Why use jQuery? Helps us to simplify and speed up web development Allows us to avoid common headaches associated with cross-browser development Provides a large pool of plugins Large and active community Tested on 50 browsers, 11 platforms and mobile It’s for both developers and designers
  • 19. Where to get jQuery Download the source from Github Or use a CDN jQuery CDN (Edgecast via (mt) http://code.jquery.com/jquery-1.4.2.min.js Minified version http://code.jquery.com/jquery-1.4.2.js Source version Google Microsoft
  • 20. Core jQuery Concepts Select Something, do something Create something, do something Chaining and Operating Demo’d http://ejohn.org/apps/learn-jquery/ and http://ralphwhitbeck.com/talks/stackoverflowdevdays/createdosomething.html
  • 21. jQuery API Overview Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities You can review Core Methods at: http://api.jquery.com
  • 22. jQuery Plugins   There are over 2200 plugins Plugins extend jQuery’s functionality If you can’t find the functionality in a plugin, make your own! You can make a jQuery Plugin in six steps
  • 23. Step 1. create a private scope for $ alias <!DOCTYPE html><html><body> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ })(jQuery); </script></body></html> A jQuery plugin in 6 steps
  • 24. Step 2. attach plugin to fn alias <!DOCTYPE html><html><body> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ $(this).text($(this).text().replace(/hate/g,'love')); }; })(jQuery); </script></body></html> A jQuery plugin in 6 steps
  • 25. Step 2. attach plugin to fn alias <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ $(this).text($(this).text().replace(/hate/g,'love')); }; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
  • 26. Step 3. add implicit iteration <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love')); }); }; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
  • 27. Step 3. add implicit iteration <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love')); }); }; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
  • 28. Step 4. enable chaining <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ return this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love')); }); }; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
  • 29. Step 4. enable chaining <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ return this.each(function(){ $(this).text($(this).text().replace(/hate/g,'love')); }); }; })(jQuery); jQuery('p').loveNotHate() .hide() ; </script></body></html> A jQuery plugin in 6 steps
  • 30. Step 5. add default options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text )); }); }; $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate(); </script></body></html> A jQuery plugin in 6 steps
  • 31. Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function(){ return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text)); }); }; $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
  • 32. Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function( customOptions ){ return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text)); }); }; $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
  • 33. Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function( customOptions ){ var options = $.extend({},$.fn.loveNotHate.defaultOptions, customOptions); return this.each(function(){ $(this).text($(this).text().replace(/hate/g, $.fn.loveNotHate.defaultOptions.text)); }); }; $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
  • 34. Step 6. add custom options <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;></script> <script> (function($){ $.fn.loveNotHate = function( customOptions ){ var options = $.extend({},$.fn.loveNotHate.defaultOptions, customOptions); return this.each(function(){ $(this).text($(this).text().replace(/hate/g, options.text )); }); }; $.fn.loveNotHate.defaultOptions = {text:'love'}; })(jQuery); jQuery('p').loveNotHate( {text:'love-love-love'} ); </script></body></html> A jQuery plugin in 6 steps
  • 35. Plugins are simple, just follow the steps!
  • 36. jQuery UI   Official jQuery Project Provides plugins that make user interface elements easy Contains: Interactions Widgets Effects Theming

Editor's Notes

  • #8: It simplifies…
  • #14: Wrapped Set , is an array like structure that contains each of the selected DOM elements. You can iterate over the wrapped set like an array or access individual elements via the indexer. More importantly though you can also apply jQuery functions against all the selected elements.
  • #18: Any good JavaScript framework will do these top two points
  • #19: It’s these last four that really set jQuery apart
  • #20: It’s these last four that really set jQuery apart
  • #21: Learn jQuery Effects Demo
  • #22: Show AIR APP (Screen 4) The API is broken up to help you find what you need to do one of the core jquery functions select, create, do something then do something else. The API is categorized by functionality
  • #24: Create a private scope for the jQuery Alias
  • #37: So what do you need to do to be able to use jQuery on your page.