SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

jQuery