SlideShare a Scribd company logo
Sudar ( http://SudarMuthu.com ) WebCamp Chennai – 23 Feb 2008
Famous Client – Side frameworks jQuery Prototype Yahoo User Interface Library (YUI) Dojo Rico WebCamp - Chennai http://SudarMuthu.com
The $() function Build around CSS selectors WordPress has started to use jQuery Lots of Plugins Can be used with other libraries Doesn’t hijack the global namespace Small Size (Just 15 KB after Minified and Gzipped) Write Less, Do More WebCamp - Chennai http://SudarMuthu.com
Matches a set of elements and returns a collection.  Uses CSS Selectors $ (‘#comment’) $(‘div.comment’) $(‘div#content h2’) $(‘input:password’) $(‘a[href^=“http://”]’) $(‘ul#nav > li’) You can also use jQuery() instead of $() WebCamp - Chennai http://SudarMuthu.com
$ (‘h2:first’) $(‘h2:last’) $(‘p:visible’) $(‘p:hidden’) $(‘input:password’) $(‘input:text’) $(‘p:odd’) WebCamp - Chennai http://SudarMuthu.com
The $ () function returns a collection consisting of  the elements that match the selector.  It is similar to an array, but not exactly same. You can use  $(‘p.special’).length or  $(‘p.special’).size() Both return the number of matched elements WebCamp - Chennai http://SudarMuthu.com
You can use .each() to iterate the collection $(‘p.special’).each(function () { alert (this); }); $(‘p.special’)[0] – First element $(‘p.special’)[1] -  Second element WebCamp - Chennai http://SudarMuthu.com
Access a property of matched element $(‘img#header’).attr(‘src’) – returns the src attribute $(‘img#header’).attr(‘src’, ‘http://e.in/head.gif’) Set the src attribute WebCamp - Chennai http://SudarMuthu.com
val() – Get the value of the input element var singleValue = $(‘#single’).val(); val(val) – Set the value of an input element $("input:text"). val (“Value Text”); $(“#multiple”).val([“multiple1”, “multiple2”]); WebCamp - Chennai http://SudarMuthu.com
$(‘img#header’).addClass(‘highlighted’) $(‘img#header’).removeClass(‘highlighted’) $(‘img#header’).toggleClass(‘highlighted’) var hasBar = #(‘img#header’).hasClass(‘special’) $(‘p.special’).css(‘font-size’, ’12px’ ) $(‘p.special’).css({‘font-size’:’12px’, ‘color’:’red’ }) WebCamp - Chennai http://SudarMuthu.com
Similar to innerHTML $(‘span#error’).text(“There is some error”) $(‘div#msg’).html(“<strong>Message</strong>”) WebCamp - Chennai http://SudarMuthu.com
$(‘span#msg’).show() Also show(speed, [callback]) $(‘span#msg’).show(“fast”, function() { alert (“Done”); }); $(‘span#msg’).hide() Also hide(speed, [callback]) WebCamp - Chennai http://SudarMuthu.com
toggle() fadeIn() fadeOut() fadeTo() slideUp() slideDown() animate() stop() WebCamp - Chennai http://SudarMuthu.com
Enhanced methods for traversing DOM $(‘div#nav’).parent() $(‘div#nav’).next() $(‘div#nav’).prev() $(‘div#nav’).nextAll(‘a’) WebCamp - Chennai http://SudarMuthu.com
Enhanced methods for manipulating DOM after(content) append(content) before(content) clone() empty() remove(expr) WebCamp - Chennai http://SudarMuthu.com
Provides methods for assigning events in a cross  browser way $(‘div#msg’).click(function(ev) { $(this).css(‘color’, ‘red’); alert(‘Clicked’); }); Lot of other handlers also available WebCamp - Chennai http://SudarMuthu.com
Alternate to onLoad event $(document).ready(function() { alert (“DOM is Ready”); }); You can also use $(function() { alert (“DOM is Ready”); }); WebCamp - Chennai http://SudarMuthu.com
jQuery has excellent support for AJAX $(‘div#msg’).load(‘/dir/file.html’) You can also use other advanced methods $.get(url, params, callback) $.post(url, params, callback) $.getJSON(url, params, callback) $.getScript(url, callback) WebCamp - Chennai http://SudarMuthu.com
$.trim(str) $.browser if ($.browser.safari) { alert(“This is Safari”); } You can also use safari opera msie Mozilla $.each(object, callback) WebCamp - Chennai http://SudarMuthu.com
Lot of Plugins available for Form Validation Drop down Menus UI Drag and Drop Etc.., Official Plugin repository at  http://plugins.jquery.com/ WebCamp - Chennai http://SudarMuthu.com
http://jquery.com  – Official Site http://docs.jquery.com  - Documentation http://plugins.jquery.com  – Plugin repositry http://visualjquery.com  – API Reference http://sudarmuthu.com/blog/tag/jquery  - My blog posts about jQuery WebCamp - Chennai http://SudarMuthu.com

More Related Content

What's hot (20)

PPTX
jQuery Presentation
Rod Johnson
 
PDF
jQuery Loves Developers - Oredev 2009
Remy Sharp
 
PPTX
jQuery from the very beginning
Anis Ahmad
 
PDF
Prototype & jQuery
Remy Sharp
 
PPTX
JavaScript and jQuery Basics
Kaloyan Kosev
 
PDF
jQuery Essentials
Marc Grabanski
 
PDF
jQuery in 15 minutes
Simon Willison
 
PPTX
jQuery Fundamentals
Gil Fink
 
PDF
Write Less Do More
Remy Sharp
 
PPTX
jQuery
Jay Poojara
 
PDF
jQuery for beginners
Siva Arunachalam
 
PPTX
Jquery introduction
musrath mohammad
 
PDF
jQuery Essentials
Bedis ElAchèche
 
PDF
jQuery Introduction
Arwid Bancewicz
 
ODP
Drupal Best Practices
manugoel2003
 
PPTX
jQuery PPT
Dominic Arrojado
 
PPT
jQuery
Mostafa Bayomi
 
PPTX
Unobtrusive javascript with jQuery
Angel Ruiz
 
PPTX
Introduction to jQuery
Gunjan Kumar
 
PPTX
Jquery-overview
Isfand yar Khan
 
jQuery Presentation
Rod Johnson
 
jQuery Loves Developers - Oredev 2009
Remy Sharp
 
jQuery from the very beginning
Anis Ahmad
 
Prototype & jQuery
Remy Sharp
 
JavaScript and jQuery Basics
Kaloyan Kosev
 
jQuery Essentials
Marc Grabanski
 
jQuery in 15 minutes
Simon Willison
 
jQuery Fundamentals
Gil Fink
 
Write Less Do More
Remy Sharp
 
jQuery
Jay Poojara
 
jQuery for beginners
Siva Arunachalam
 
Jquery introduction
musrath mohammad
 
jQuery Essentials
Bedis ElAchèche
 
jQuery Introduction
Arwid Bancewicz
 
Drupal Best Practices
manugoel2003
 
jQuery PPT
Dominic Arrojado
 
Unobtrusive javascript with jQuery
Angel Ruiz
 
Introduction to jQuery
Gunjan Kumar
 
Jquery-overview
Isfand yar Khan
 

Similar to A Short Introduction To jQuery (20)

PPTX
Jquery optimization-tips
anubavam-techkt
 
PDF
Learning jquery-in-30-minutes-1195942580702664-3
luckysb16
 
PDF
fuser interface-development-using-jquery
Kostas Mavridis
 
PPTX
Working With JQuery Part1
saydin_soft
 
KEY
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
PDF
Remy Sharp The DOM scripting toolkit jQuery
deimos
 
KEY
jQuery Anti-Patterns for Performance
András Kovács
 
PPTX
Iniciando com jquery
Danilo Sousa
 
KEY
User Interface Development with jQuery
colinbdclark
 
KEY
Week 4 - jQuery + Ajax
baygross
 
PDF
The Dom Scripting Toolkit J Query
QConLondon2008
 
PPT
Kick start with j query
Md. Ziaul Haq
 
PDF
jQuery
Ivano Malavolta
 
PDF
J query fundamentals
Attaporn Ninsuwan
 
PPTX
jQuery, CSS3 and ColdFusion
Denard Springle IV
 
PPTX
Jquery fundamentals
Salvatore Fazio
 
PPTX
jQuery
Jeremiah Gatong
 
PPT
jQuery
Niladri Karmakar
 
PPT
jQuery Tips Tricks Trivia
Cognizant
 
KEY
Bcblackpool jquery tips
Jack Franklin
 
Jquery optimization-tips
anubavam-techkt
 
Learning jquery-in-30-minutes-1195942580702664-3
luckysb16
 
fuser interface-development-using-jquery
Kostas Mavridis
 
Working With JQuery Part1
saydin_soft
 
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
Remy Sharp The DOM scripting toolkit jQuery
deimos
 
jQuery Anti-Patterns for Performance
András Kovács
 
Iniciando com jquery
Danilo Sousa
 
User Interface Development with jQuery
colinbdclark
 
Week 4 - jQuery + Ajax
baygross
 
The Dom Scripting Toolkit J Query
QConLondon2008
 
Kick start with j query
Md. Ziaul Haq
 
J query fundamentals
Attaporn Ninsuwan
 
jQuery, CSS3 and ColdFusion
Denard Springle IV
 
Jquery fundamentals
Salvatore Fazio
 
jQuery Tips Tricks Trivia
Cognizant
 
Bcblackpool jquery tips
Jack Franklin
 
Ad

More from Sudar Muthu (20)

PPTX
A quick preview of WP CLI - Chennai WordPress Meetup
Sudar Muthu
 
PDF
WordPress Developer tools
Sudar Muthu
 
PDF
WordPress Developer Tools to increase productivity
Sudar Muthu
 
PDF
Unit testing for WordPress
Sudar Muthu
 
PDF
Unit testing in php
Sudar Muthu
 
PPTX
Using arduino and raspberry pi for internet of things
Sudar Muthu
 
PPTX
How arduino helped me in life
Sudar Muthu
 
PPTX
Having fun with hardware
Sudar Muthu
 
PPTX
Getting started with arduino workshop
Sudar Muthu
 
PPTX
Python in raspberry pi
Sudar Muthu
 
PPTX
Hack 101 at IIT Kanpur
Sudar Muthu
 
PPTX
PureCSS open hack 2013
Sudar Muthu
 
PPTX
Pig workshop
Sudar Muthu
 
PPTX
Arduino Robotics workshop day2
Sudar Muthu
 
PPTX
Arduino Robotics workshop Day1
Sudar Muthu
 
PPTX
Hands on Hadoop and pig
Sudar Muthu
 
PPTX
Lets make robots
Sudar Muthu
 
PPTX
Capabilities of Arduino (including Due)
Sudar Muthu
 
PPTX
Controlling robots using javascript
Sudar Muthu
 
PPTX
Picture perfect hacks with flickr API
Sudar Muthu
 
A quick preview of WP CLI - Chennai WordPress Meetup
Sudar Muthu
 
WordPress Developer tools
Sudar Muthu
 
WordPress Developer Tools to increase productivity
Sudar Muthu
 
Unit testing for WordPress
Sudar Muthu
 
Unit testing in php
Sudar Muthu
 
Using arduino and raspberry pi for internet of things
Sudar Muthu
 
How arduino helped me in life
Sudar Muthu
 
Having fun with hardware
Sudar Muthu
 
Getting started with arduino workshop
Sudar Muthu
 
Python in raspberry pi
Sudar Muthu
 
Hack 101 at IIT Kanpur
Sudar Muthu
 
PureCSS open hack 2013
Sudar Muthu
 
Pig workshop
Sudar Muthu
 
Arduino Robotics workshop day2
Sudar Muthu
 
Arduino Robotics workshop Day1
Sudar Muthu
 
Hands on Hadoop and pig
Sudar Muthu
 
Lets make robots
Sudar Muthu
 
Capabilities of Arduino (including Due)
Sudar Muthu
 
Controlling robots using javascript
Sudar Muthu
 
Picture perfect hacks with flickr API
Sudar Muthu
 
Ad

Recently uploaded (20)

PDF
Gabino Barbosa - A Master Of Efficiency
Gabino Barbosa
 
PDF
NewBase 03 July 2025 Energy News issue - 1799 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
PDF
Step-by-Step: Buying a Verified Cash App Accounts| PDF | Payments Service
https://pvabulkpro.com/
 
PDF
Top 10 Emerging Tech Trends to Watch in 2025.pdf
marketingyourtechdig
 
PDF
Smart Lead Magnet Review: Effortless Email List Growth with Automated Funnels...
Larry888358
 
PDF
FastnersFastnersFastnersFastnersFastners
mizhanw168
 
PDF
20250703_A. Stotz All Weather Strategy - Performance review July
FINNOMENAMarketing
 
PPTX
Asia Pacific Tropical Fruit Puree Market Overview & Growth
chanderdeepseoexpert
 
PDF
Cloud Budgeting for Startups: Principles, Strategies, and Tools That Scale
Amnic
 
PDF
Top Supply Chain Management Tools Transforming Global Logistics.pdf
Enterprise Wired
 
DOCX
TCP Communication Flag Txzczczxcxzzxypes.docx
esso24
 
PDF
Agriculture Machinery PartsAgriculture Machinery Parts
mizhanw168
 
PDF
Buy Facebook Accounts Buy Facebook Accounts
darlaknowles49
 
PPTX
Oil and Gas EPC Market Size & Share | Growth - 2034
Aman Bansal
 
PPTX
Event Budgeting. Various factors to consider for event budgeting
TintoAnil
 
PPTX
Technical Analysis of 1st Generation Biofuel Feedstocks - 25th June 2025
TOFPIK
 
PDF
_How Freshers Can Find the Best IT Companies in Jaipur with Salarite.pdf
SALARITE
 
PDF
"Complete Guide to the Partner Visa 2025
Zealand Immigration
 
PPTX
Micro Battery Market Size & Share | Growth - 2034
Aman Bansal
 
PDF
HOW TO RECOVER LOST CRYPTOCURRENCY - VISIT iBOLT CYBER HACKER COMPANY
diegovalentin771
 
Gabino Barbosa - A Master Of Efficiency
Gabino Barbosa
 
NewBase 03 July 2025 Energy News issue - 1799 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
Step-by-Step: Buying a Verified Cash App Accounts| PDF | Payments Service
https://pvabulkpro.com/
 
Top 10 Emerging Tech Trends to Watch in 2025.pdf
marketingyourtechdig
 
Smart Lead Magnet Review: Effortless Email List Growth with Automated Funnels...
Larry888358
 
FastnersFastnersFastnersFastnersFastners
mizhanw168
 
20250703_A. Stotz All Weather Strategy - Performance review July
FINNOMENAMarketing
 
Asia Pacific Tropical Fruit Puree Market Overview & Growth
chanderdeepseoexpert
 
Cloud Budgeting for Startups: Principles, Strategies, and Tools That Scale
Amnic
 
Top Supply Chain Management Tools Transforming Global Logistics.pdf
Enterprise Wired
 
TCP Communication Flag Txzczczxcxzzxypes.docx
esso24
 
Agriculture Machinery PartsAgriculture Machinery Parts
mizhanw168
 
Buy Facebook Accounts Buy Facebook Accounts
darlaknowles49
 
Oil and Gas EPC Market Size & Share | Growth - 2034
Aman Bansal
 
Event Budgeting. Various factors to consider for event budgeting
TintoAnil
 
Technical Analysis of 1st Generation Biofuel Feedstocks - 25th June 2025
TOFPIK
 
_How Freshers Can Find the Best IT Companies in Jaipur with Salarite.pdf
SALARITE
 
"Complete Guide to the Partner Visa 2025
Zealand Immigration
 
Micro Battery Market Size & Share | Growth - 2034
Aman Bansal
 
HOW TO RECOVER LOST CRYPTOCURRENCY - VISIT iBOLT CYBER HACKER COMPANY
diegovalentin771
 

A Short Introduction To jQuery

  • 2. Famous Client – Side frameworks jQuery Prototype Yahoo User Interface Library (YUI) Dojo Rico WebCamp - Chennai http://SudarMuthu.com
  • 3. The $() function Build around CSS selectors WordPress has started to use jQuery Lots of Plugins Can be used with other libraries Doesn’t hijack the global namespace Small Size (Just 15 KB after Minified and Gzipped) Write Less, Do More WebCamp - Chennai http://SudarMuthu.com
  • 4. Matches a set of elements and returns a collection. Uses CSS Selectors $ (‘#comment’) $(‘div.comment’) $(‘div#content h2’) $(‘input:password’) $(‘a[href^=“http://”]’) $(‘ul#nav > li’) You can also use jQuery() instead of $() WebCamp - Chennai http://SudarMuthu.com
  • 5. $ (‘h2:first’) $(‘h2:last’) $(‘p:visible’) $(‘p:hidden’) $(‘input:password’) $(‘input:text’) $(‘p:odd’) WebCamp - Chennai http://SudarMuthu.com
  • 6. The $ () function returns a collection consisting of the elements that match the selector. It is similar to an array, but not exactly same. You can use $(‘p.special’).length or $(‘p.special’).size() Both return the number of matched elements WebCamp - Chennai http://SudarMuthu.com
  • 7. You can use .each() to iterate the collection $(‘p.special’).each(function () { alert (this); }); $(‘p.special’)[0] – First element $(‘p.special’)[1] - Second element WebCamp - Chennai http://SudarMuthu.com
  • 8. Access a property of matched element $(‘img#header’).attr(‘src’) – returns the src attribute $(‘img#header’).attr(‘src’, ‘http://e.in/head.gif’) Set the src attribute WebCamp - Chennai http://SudarMuthu.com
  • 9. val() – Get the value of the input element var singleValue = $(‘#single’).val(); val(val) – Set the value of an input element $(&quot;input:text&quot;). val (“Value Text”); $(“#multiple”).val([“multiple1”, “multiple2”]); WebCamp - Chennai http://SudarMuthu.com
  • 10. $(‘img#header’).addClass(‘highlighted’) $(‘img#header’).removeClass(‘highlighted’) $(‘img#header’).toggleClass(‘highlighted’) var hasBar = #(‘img#header’).hasClass(‘special’) $(‘p.special’).css(‘font-size’, ’12px’ ) $(‘p.special’).css({‘font-size’:’12px’, ‘color’:’red’ }) WebCamp - Chennai http://SudarMuthu.com
  • 11. Similar to innerHTML $(‘span#error’).text(“There is some error”) $(‘div#msg’).html(“<strong>Message</strong>”) WebCamp - Chennai http://SudarMuthu.com
  • 12. $(‘span#msg’).show() Also show(speed, [callback]) $(‘span#msg’).show(“fast”, function() { alert (“Done”); }); $(‘span#msg’).hide() Also hide(speed, [callback]) WebCamp - Chennai http://SudarMuthu.com
  • 13. toggle() fadeIn() fadeOut() fadeTo() slideUp() slideDown() animate() stop() WebCamp - Chennai http://SudarMuthu.com
  • 14. Enhanced methods for traversing DOM $(‘div#nav’).parent() $(‘div#nav’).next() $(‘div#nav’).prev() $(‘div#nav’).nextAll(‘a’) WebCamp - Chennai http://SudarMuthu.com
  • 15. Enhanced methods for manipulating DOM after(content) append(content) before(content) clone() empty() remove(expr) WebCamp - Chennai http://SudarMuthu.com
  • 16. Provides methods for assigning events in a cross browser way $(‘div#msg’).click(function(ev) { $(this).css(‘color’, ‘red’); alert(‘Clicked’); }); Lot of other handlers also available WebCamp - Chennai http://SudarMuthu.com
  • 17. Alternate to onLoad event $(document).ready(function() { alert (“DOM is Ready”); }); You can also use $(function() { alert (“DOM is Ready”); }); WebCamp - Chennai http://SudarMuthu.com
  • 18. jQuery has excellent support for AJAX $(‘div#msg’).load(‘/dir/file.html’) You can also use other advanced methods $.get(url, params, callback) $.post(url, params, callback) $.getJSON(url, params, callback) $.getScript(url, callback) WebCamp - Chennai http://SudarMuthu.com
  • 19. $.trim(str) $.browser if ($.browser.safari) { alert(“This is Safari”); } You can also use safari opera msie Mozilla $.each(object, callback) WebCamp - Chennai http://SudarMuthu.com
  • 20. Lot of Plugins available for Form Validation Drop down Menus UI Drag and Drop Etc.., Official Plugin repository at http://plugins.jquery.com/ WebCamp - Chennai http://SudarMuthu.com
  • 21. http://jquery.com – Official Site http://docs.jquery.com - Documentation http://plugins.jquery.com – Plugin repositry http://visualjquery.com – API Reference http://sudarmuthu.com/blog/tag/jquery - My blog posts about jQuery WebCamp - Chennai http://SudarMuthu.com