SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Short	
  into	
  to	
  JQuery	
  and	
  
          Modernizr	
  
            Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  Applied	
  Sciences	
  
JQuery?	
  
•  Mo?va?on	
  
   –  Simple	
  things	
  may	
  require	
  lot	
  of	
  coding	
  
   –  Common	
  browsers	
  are	
  different	
  and	
  
      implementa?on	
  varies	
  
•  Solu?on,	
  use	
  a	
  framework	
  
   –  jQuery	
  is	
  a	
  fast	
  and	
  concise	
  JavaScript	
  Library	
  that	
  
        simplifies	
  HTML	
  document	
  traversing,	
  event	
  
        handling,	
  anima?ng,	
  and	
  Ajax	
  interac?ons	
  for	
  
        rapid	
  web	
  development.	
  	
  
   	
  
How?	
  
•  Download	
  JQuery	
  file	
  (hOp://jquery.com/)	
  
    –  hOp://code.jquery.com/jquery-­‐1.7.1.min.js	
  
•  Make	
  your	
  xhtml	
  page	
  and	
  reference	
  to	
  the	
  
   file	
  in	
  script	
  block	
  
•  Make	
  your	
  code	
  and	
  use	
  JQuery	
  func?ons!	
  
<script type="text/javascript" src="jquery.js"></script>

   <script type="text/javascript">
   //<![CDATA[

    // When document is ready to be manipulated
    jQuery(document).ready( pageReadyToBeManipulated );

    function pageReadyToBeManipulated() {
        // If link is clicked
        jQuery("a").click( linkClick );
    }

    function linkClick(event) {
        alert("Thanks for visiting!");
        // Prevent the default action
        event.preventDefault();
    }

    //]]>
   </script>
Some	
  Basic	
  Syntax	
  
•  JQuery	
  can	
  be	
  used	
  in	
  two	
  ways:	
  
    –  JQuery()	
  
    –  Or	
  
    –  $()	
  
•  $	
  is	
  an	
  alias	
  to	
  JQuery()!	
  $	
  more	
  commonly	
  
   used	
  
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
//<![CDATA[

 // When document is ready to be manipulated
 $(document).ready( pageReadyToBeManipulated );

 function pageReadyToBeManipulated() {
     // If link is clicked
     $("a").click( linkClick );
 }

 function linkClick(event) {
     alert("Thanks for visiting!");
     // Prevent the default action
     event.preventDefault();
 }

 //]]>
</script>
// USING ANONYMOUS FUNCTIONS

<script type="text/javascript" src="jquery.js"></script>

 <script type="text/javascript">
 //<![CDATA[

  $(document).ready(function(){
      $("a").click(function(event){
          alert("Thanks for visiting!");
          event.preventDefault();
      });
  });

  //]]>
 </script>
// EVEN SHORTER SYNTAX, FORGET THE DOCUMENT PARAMETER

<script type="text/javascript" src="jquery.js"></script>

 <script type="text/javascript">
 //<![CDATA[

  $().ready(function(){
      $("a").click(function(event){
          alert("Thanks for visiting!");
          event.preventDefault();
      });
  });

  //]]>
 </script>
GeOers	
  in	
  the	
  Tradi?onal	
  Way	
  
•  getElementsById

•  getElementsByTagName

•  getAttribute
JQuery	
  and	
  Selectors	
  
•  Select	
  all	
  h1	
  elements	
  
    –  $(“h1”)	
  
•  Select	
  the	
  first	
  one	
  
    –  $(“h1”)[0]	
  
•  Add	
  contents	
  
    –  $(“h1”)[0].innerHTML	
  =	
  “hello!”;	
  
•  Lot	
  of	
  different	
  selectors	
  
    –  hOp://api.jquery.com/category/selectors/	
  
Crea?ng	
  Elements	
  in	
  Tradi?onal	
  Way	
  
•    createElement
•    createTextNode
•    setAttribute
•    appendChild
•    removeChild
JQuery	
  Insert	
  
$().ready(function(){
       $("a").click(function(event){

               // Insert the new element after element with id here
               $("<p>New Element</p>").insertAfter("#here");

               event.preventDefault();
         });
   });
Manipula?on	
  Func?ons	
  
•    .addClass()	
  
•    .afer()	
  
•    .append()	
  
•    .css()	
  
•    …	
  
•    See:	
  hOp://api.jquery.com/category/
     manipula?on/	
  
Some	
  Effects:	
  Lot	
  of	
  Anim	
  Func?ons	
  
$('#clickme').click(function() {
  $('#book').slideUp('slow', function() {
    // Animation complete.
  });
});
MODERNIZR	
  
Modernizr	
  
•  Small	
  JS	
  library	
  for	
  detec?ng	
  browser	
  features	
  
•  Replaces	
  highly	
  unreliable	
  user	
  agent	
  sniffing	
  
•  Feature	
  detec?on	
  for	
  each	
  browser	
  what	
  the	
  
   browser	
  can	
  or	
  cannot	
  do	
  
•  Tests	
  over	
  40	
  features	
  
    –  Creates	
  Modernizr	
  object	
  containing	
  the	
  results	
  
How	
  
•  Download	
  and	
  install	
  modernizr.js	
  
•  Add	
  
    –  <html	
  class=“no-­‐js”>	
  
•  Modernizr	
  replaces	
  this	
  
    –  <html	
  class=“canvas	
  canvastext	
  geoloca?on..”>	
  
•  Classes	
  for	
  every	
  feature	
  it	
  detects!	
  
Adding	
  CSS	
  
Result	
  
HTML5	
  and	
  Video	
  
Solu?on	
  

Más contenido relacionado

La actualidad más candente

Quick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery Mobile
Jussi Pohjolainen
 
Auto tools
Auto toolsAuto tools
Auto tools
祺 周
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
jeresig
 

La actualidad más candente (18)

jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Quick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery Mobile
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
Auto tools
Auto toolsAuto tools
Auto tools
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
 
Client-side Transformations
Client-side TransformationsClient-side Transformations
Client-side Transformations
 
Javascript and jQuery intro
Javascript and jQuery introJavascript and jQuery intro
Javascript and jQuery intro
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Casl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptxCasl. isomorphic permission management.pptx
Casl. isomorphic permission management.pptx
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
 

Similar a Short intro to JQuery and Modernizr

Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
Gonzalo Parra
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
Mark Rackley
 
J query presentation
J query presentationJ query presentation
J query presentation
akanksha17
 
J query presentation
J query presentationJ query presentation
J query presentation
sawarkar17
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile20111014 mu me_j_querymobile
20111014 mu me_j_querymobile
Erik Duval
 

Similar a Short intro to JQuery and Modernizr (20)

JQuery
JQueryJQuery
JQuery
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
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...
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
JQuery
JQueryJQuery
JQuery
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
J query training
J query trainingJ query training
J query training
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
 
Introduction to jquery mobile with Phonegap
Introduction to jquery mobile with PhonegapIntroduction to jquery mobile with Phonegap
Introduction to jquery mobile with Phonegap
 
J query presentation
J query presentationJ query presentation
J query presentation
 
J query presentation
J query presentationJ query presentation
J query presentation
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile20111014 mu me_j_querymobile
20111014 mu me_j_querymobile
 

Más de Jussi Pohjolainen

Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
Jussi Pohjolainen
 

Más de Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 

Último

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
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
 

Último (20)

AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
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
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 

Short intro to JQuery and Modernizr

  • 1. Short  into  to  JQuery  and   Modernizr   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 2. JQuery?   •  Mo?va?on   –  Simple  things  may  require  lot  of  coding   –  Common  browsers  are  different  and   implementa?on  varies   •  Solu?on,  use  a  framework   –  jQuery  is  a  fast  and  concise  JavaScript  Library  that   simplifies  HTML  document  traversing,  event   handling,  anima?ng,  and  Ajax  interac?ons  for   rapid  web  development.      
  • 3. How?   •  Download  JQuery  file  (hOp://jquery.com/)   –  hOp://code.jquery.com/jquery-­‐1.7.1.min.js   •  Make  your  xhtml  page  and  reference  to  the   file  in  script  block   •  Make  your  code  and  use  JQuery  func?ons!  
  • 4. <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ // When document is ready to be manipulated jQuery(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clicked jQuery("a").click( linkClick ); } function linkClick(event) { alert("Thanks for visiting!"); // Prevent the default action event.preventDefault(); } //]]> </script>
  • 5. Some  Basic  Syntax   •  JQuery  can  be  used  in  two  ways:   –  JQuery()   –  Or   –  $()   •  $  is  an  alias  to  JQuery()!  $  more  commonly   used  
  • 6. <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ // When document is ready to be manipulated $(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clicked $("a").click( linkClick ); } function linkClick(event) { alert("Thanks for visiting!"); // Prevent the default action event.preventDefault(); } //]]> </script>
  • 7. // USING ANONYMOUS FUNCTIONS <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function(){ $("a").click(function(event){ alert("Thanks for visiting!"); event.preventDefault(); }); }); //]]> </script>
  • 8. // EVEN SHORTER SYNTAX, FORGET THE DOCUMENT PARAMETER <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ $().ready(function(){ $("a").click(function(event){ alert("Thanks for visiting!"); event.preventDefault(); }); }); //]]> </script>
  • 9. GeOers  in  the  Tradi?onal  Way   •  getElementsById •  getElementsByTagName •  getAttribute
  • 10. JQuery  and  Selectors   •  Select  all  h1  elements   –  $(“h1”)   •  Select  the  first  one   –  $(“h1”)[0]   •  Add  contents   –  $(“h1”)[0].innerHTML  =  “hello!”;   •  Lot  of  different  selectors   –  hOp://api.jquery.com/category/selectors/  
  • 11. Crea?ng  Elements  in  Tradi?onal  Way   •  createElement •  createTextNode •  setAttribute •  appendChild •  removeChild
  • 12. JQuery  Insert   $().ready(function(){ $("a").click(function(event){ // Insert the new element after element with id here $("<p>New Element</p>").insertAfter("#here"); event.preventDefault(); }); });
  • 13. Manipula?on  Func?ons   •  .addClass()   •  .afer()   •  .append()   •  .css()   •  …   •  See:  hOp://api.jquery.com/category/ manipula?on/  
  • 14. Some  Effects:  Lot  of  Anim  Func?ons   $('#clickme').click(function() { $('#book').slideUp('slow', function() { // Animation complete. }); });
  • 16. Modernizr   •  Small  JS  library  for  detec?ng  browser  features   •  Replaces  highly  unreliable  user  agent  sniffing   •  Feature  detec?on  for  each  browser  what  the   browser  can  or  cannot  do   •  Tests  over  40  features   –  Creates  Modernizr  object  containing  the  results  
  • 17. How   •  Download  and  install  modernizr.js   •  Add   –  <html  class=“no-­‐js”>   •  Modernizr  replaces  this   –  <html  class=“canvas  canvastext  geoloca?on..”>   •  Classes  for  every  feature  it  detects!  
  • 18.