SlideShare a Scribd company logo
1 of 39
Download to read offline
jQuery
   v. 1.3.2
Andrew Homeyer
  with Near Infinity since July ‘08




  twitter: @andrewhomeyer
ajaxrain.com
http://www.google.com/insights/search/#cat=422&q=jquery%2Cprototype&date=1%2F2006%2045m&cmpt=q
http://www.google.com/insights/search/#cat=422&q=jquery%2Cprototype%2Cmootools%2Cdojo%2CYUI&date=1%2F2006%2045m&cmpt=q
How it’s gonna go down:
 jQuery:

 $(‘li:last’).css(‘backgroundColor’, ‘red’);




Prototype:

$$(‘li’).last().setStyle({‘backgroundColor’: ‘red’});
$( )
jQuery( )
Play nice with others

   jQuery.noConflict();
Selecting elements

      $(‘#mydiv’)    //element with id mydiv




             $(‘mydiv’)
$(‘div’)   //all div elements on page




      $$(‘div’)
$(‘div.warning’)     //all div elements
                     with class of warning




        $$(‘div.warning’)
$(‘*’)   //everything




    $$(‘*’)
selecting with filters

                                   // all spans that contain
 $(‘span:has(img)’)                an image




       $$('span').findAll(function(v){
           return v.select('img').length > 0;
       });
$(‘.mytable tr:even’)       //even rows




  $$(‘.mytable tr:nth-child(even)’)
:first            :empty
:last             :has(selector)
:not(selector)    :parent
:even             :hidden
:odd              :visible
:eq(index)        :checked
:animated         :selected
:contains(text)   :input
:first            :empty
:last             :has(selector)
:not(selector)    :parent
:even             :hidden
:odd              :visible
:eq(index)        :checked
:animated         :selected
:contains(text)   :input
creating elements

    $(‘<a></a>’)     //returns a new <a>




           new Element(‘a’)
$(‘<a></a>’).appendTo(document.body)




   document.body.insert(new Element(‘a’))
$(‘body’).append(‘<a></a>’)




      document.body.insert(‘<a></a>’)
chaining
 $(‘li’)
     .css(‘backgroundColor’, ‘red’)
     .text(‘new content’)




$$(‘li’).each(function(v){
   v.setStyle({‘backgroundColor’: ‘red’}).update(‘new content’);
}
$(‘div’)
$(‘div’).filter(function(){
    return $(this).css(‘color’) == ‘green’
})
$(‘div’).filter(function(){
     return $(this).css(‘color’) == ‘green’
})
   .remove()
$(‘div’).filter(function(){
     return $(this).css(‘color’) == ‘green’
})
   .remove()
   .end()
$(‘div’).filter(function(){
     return $(this).css(‘color’) == ‘green’
})
   .remove()
   .end()
.text(“no green divs”)
events
$(‘a’).click(function(){
    $(this).slideUp();
})




$$(‘a’).each(function(v){
    v.observe(‘click’, function(a){
        Effect.SlideUp(a);
    });
});
effects

$(‘#box’).show(‘slow’);




              $(‘box’).appear();
show
hide          fadeIn
toggle        fadeOut
slideDown     fadeTo
slideUp       animate
slideToggle
short circuit effects

jQuery.fx.off = true;
ajax
  $.ajax({
      url:'ajax.json',
      dataType: 'json',
      error: function(xhr, textStatus, errorThrown){
         console.log(textStatus);
      },
      success: function(data, textStatus){
         console.log(data);
      }
  });



new Ajax.Request(url, {options})
ajax
  $(‘#container’).load(‘content.html’)




new Ajax.Updater(‘container’, ‘content.html’);
ajax with JSONP
$.getJSON(url, function(data){
    //process your data
});
Waiting for the DOM
  <script type=“text/javascript”>

  $(document).ready(function(){
       //DOM’s loaded, do your stuff
  });

  </script>



     document.observe(‘dom:loaded’, function(){

     });
shortcut
 <script type=“text/javascript”>

 $(function(){
      //DOM’s loaded, do your stuff
 });

 </script>
plugins
http://plugins.jquery.com/
many great ones out there, and if it’s not, write your own

    jQuery.fn.pluck = function(attribute){
	   	 var plucked = [];
	   	 this.each(function(){
	   	 	 plucked.push($(this).attr(attribute));
	   	 });
	   	 return plucked;
	   };
references
jQuery Enlightenment (http://jqueryenlightenment.com/)

API: docs.jquery.com, visualjquery.com

More Related Content

What's hot

Crash Course to SQL in PHP
Crash Course to SQL in PHPCrash Course to SQL in PHP
Crash Course to SQL in PHP
webhostingguy
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
Remy Sharp
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
girish82
 

What's hot (20)

PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integração
 
Hidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysHidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeys
 
WordPress-Powered Portfolios
WordPress-Powered PortfoliosWordPress-Powered Portfolios
WordPress-Powered Portfolios
 
Introduction to jQuery - The basics
Introduction to jQuery - The basicsIntroduction to jQuery - The basics
Introduction to jQuery - The basics
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS Services
 
J query training
J query trainingJ query training
J query training
 
Crash Course to SQL in PHP
Crash Course to SQL in PHPCrash Course to SQL in PHP
Crash Course to SQL in PHP
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
Real Time App with Node.js
Real Time App with Node.jsReal Time App with Node.js
Real Time App with Node.js
 
Basics of j query
Basics of j queryBasics of j query
Basics of j query
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Pemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQLPemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQL
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS Routing
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
jQuery Foot-Gun Features
jQuery Foot-Gun FeaturesjQuery Foot-Gun Features
jQuery Foot-Gun Features
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
 
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
 

Viewers also liked

Patient Payment Plan
Patient Payment PlanPatient Payment Plan
Patient Payment Plan
PcarrBAS
 
Cartilla final procesos
Cartilla final procesosCartilla final procesos
Cartilla final procesos
k_rito1807
 
GRAMÁTICA DE LA FANTASÍA ...
GRAMÁTICA DE LA FANTASÍA ...GRAMÁTICA DE LA FANTASÍA ...
GRAMÁTICA DE LA FANTASÍA ...
k_rito1807
 
La Gramatica De La Fantasia Rodari Gianni
La Gramatica De La Fantasia  Rodari GianniLa Gramatica De La Fantasia  Rodari Gianni
La Gramatica De La Fantasia Rodari Gianni
nenucoboy
 
Managing Money God’s Way
Managing Money God’s WayManaging Money God’s Way
Managing Money God’s Way
CRCWESTDISTRICT
 

Viewers also liked (20)

02 - Cuidado Autoestima Hijos
02 - Cuidado Autoestima Hijos02 - Cuidado Autoestima Hijos
02 - Cuidado Autoestima Hijos
 
Exploratives Testen für Entwickler, Tester und Sie
Exploratives Testen für Entwickler, Tester und SieExploratives Testen für Entwickler, Tester und Sie
Exploratives Testen für Entwickler, Tester und Sie
 
RAC Audit
RAC AuditRAC Audit
RAC Audit
 
Testing with a stranger TestNET
Testing with a stranger TestNETTesting with a stranger TestNET
Testing with a stranger TestNET
 
Akzeptanztests
AkzeptanztestsAkzeptanztests
Akzeptanztests
 
Applying good context driven testing in an agile context
Applying good context driven testing in an agile contextApplying good context driven testing in an agile context
Applying good context driven testing in an agile context
 
Patient Payment Plan
Patient Payment PlanPatient Payment Plan
Patient Payment Plan
 
Scrum im Großen und Ganzen
Scrum im Großen und GanzenScrum im Großen und Ganzen
Scrum im Großen und Ganzen
 
Thinking tools for solving three Agile adoption problems
Thinking tools for solving three Agile adoption problemsThinking tools for solving three Agile adoption problems
Thinking tools for solving three Agile adoption problems
 
Photoshop CS6 GIF ANIMADO
Photoshop CS6 GIF ANIMADOPhotoshop CS6 GIF ANIMADO
Photoshop CS6 GIF ANIMADO
 
Charla padres IES Blas Cabrera Felipe
Charla padres IES Blas Cabrera FelipeCharla padres IES Blas Cabrera Felipe
Charla padres IES Blas Cabrera Felipe
 
Cartilla final procesos
Cartilla final procesosCartilla final procesos
Cartilla final procesos
 
Orientación Andújar: 8 reglas ortográficas
Orientación Andújar: 8 reglas ortográficasOrientación Andújar: 8 reglas ortográficas
Orientación Andújar: 8 reglas ortográficas
 
Estrategias
EstrategiasEstrategias
Estrategias
 
GRAMÁTICA DE LA FANTASÍA ...
GRAMÁTICA DE LA FANTASÍA ...GRAMÁTICA DE LA FANTASÍA ...
GRAMÁTICA DE LA FANTASÍA ...
 
Proceso Oso
Proceso OsoProceso Oso
Proceso Oso
 
La Gramatica De La Fantasia Rodari Gianni
La Gramatica De La Fantasia  Rodari GianniLa Gramatica De La Fantasia  Rodari Gianni
La Gramatica De La Fantasia Rodari Gianni
 
04 dinamica de_presentacion(7)
04 dinamica de_presentacion(7)04 dinamica de_presentacion(7)
04 dinamica de_presentacion(7)
 
Managing Money God’s Way
Managing Money God’s WayManaging Money God’s Way
Managing Money God’s Way
 
Gráficas dinámicas/Laura Cárdenas
Gráficas dinámicas/Laura Cárdenas Gráficas dinámicas/Laura Cárdenas
Gráficas dinámicas/Laura Cárdenas
 

Similar to jQuery

international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
smueller_sandsmedia
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
saydin_soft
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Thomas Fuchs
 

Similar to jQuery (20)

jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
An Introduction to Jquery
An Introduction to JqueryAn Introduction to Jquery
An Introduction to Jquery
 
jQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusionjQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusion
 
jQuery
jQueryjQuery
jQuery
 
22 j query1
22 j query122 j query1
22 j query1
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
 
Unit – II (1).pptx
Unit – II (1).pptxUnit – II (1).pptx
Unit – II (1).pptx
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Javascript in Plone
Javascript in PloneJavascript in Plone
Javascript in Plone
 

Recently uploaded

Recently uploaded (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 

jQuery