SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
#1




                Day #1

          Introducing jQuery

              Wildan Maulana
       wildan.m@openthinklabs.com



     http://workshop.openthinklabs.com
Why we should use jQuery

<script type="text/javascript">
    $(function() {
      $("table tr:nth-child(even)").addClass("striped");
    });
</script>



The real power in this jQuery statement comes
from the selector, an expression
for identifying target elements on a page that
allows us to easily identify and grab
the elements we need;
What Unobtrusive JavaScript means

●   Unobtrusive JavaScript means behavior is
     separated from structure, think of it as MVC
     paradigm for JavaScript
An Example of Unobtrusive JavaScript
<button
 type="button"
 onclick="document.getElementById('xyz').style.color='red';">
   Click Me
</button>
                       <head>
                       <script type="text/javascript">
                        window.onload = function() {
                           document.getElementById('testButton').onclick = makeItRed;
                        };
                        function makeItRed() {
                           document.getElementById('xyz').style.color = 'red';
                        }
                       </script>
                       </head>
                       <body>
                       <button type="button" id="testButton">Click Me</button>
                       </body>
The Fundamental Elements and concepts of
                    jQuery
●   At its core, jQuery focuses on retrieving
      elements from our HTML pages and per-
      forming operations upon them.
●   Selector ..selector .., selector ..!
The jQuery Wapper
●   To collect a group of elements, we use the
      simple syntax :
      $(selector) or jQuery(selector)
●   $("p a") means , retrieve a group of links nested
      inside a <p> element
Query Chain
●   $("div.notLongForThisWorld").fadeOut();

●   Query Chain :

       $("div.notLongForThisWorld").fadeOut().addClass("removed");

●   $("#someElement").html("I have added some text to an element");

       same with

       $("#someElement")[0].innerHTML = "I have added some text to an element");
Query Chain - cont
●   $("div.fillMeIn").html("I have added some text to a group of
      nodes");

      same with

      var elements = $("div.fillMeIn");
      for(i=0;i<elements.length;i++)
       elements[i].innerHTML =
         "I have added some text to a group of nodes";
Advanced Selector
●   This selector is identical to the selector in CSS
●   $("p:even"); means selects all even <p> elements
●   $("tr:nth-child(1)"); means selects the first row of each table
●   $("body > div"); means selects direct <div> children of <body>.
●   $("a[href$=pdf]"); means selects link to PDF files
●   $("body > div:has(a)") means selects direct <div> children of <body> -
       containing links

       Powerfull stuff right ?!!

       You can see for full list of selector here : http://docs.jquery.com/Selectors.
About $ and jQuery()
●   $ is alias of jQuery()
●   $.trim(someString); is same with
      jQuery.trim(someString);
The document ready handler
●   To operate on a page jQuery have to wait until
      all DOM elements are fully loaded
●   Traditionally we use the onload handler
                  window.onload = function() {
                  $("table tr:nth-child(even)").addClass("even"); };

     But if we are using this method, browser will execute the load function after the
     DOM tree created and also waits until after all images and external resources are
     fully loaded and the page is displayed in the browser window
A Better Approach
●   A much better approach would be to wait only until the document structure is fully
      parsed and the browser has converted the HTML into its DOM tree form before
      executing the script to apply the rich behaviors.
●   JQuery Way :

      $(document).ready(function() {
            $("table tr:nth-child(even)").addClass("even");
      });

      or using the shorthand :

      $(function() {
        $("table tr:nth-child(even)").addClass("even");
      });
Another use of $() Function
●   Making DOM elements
<html>
 <head>
  <title>Follow me!</title>
  <script type="text/javascript" src="../scripts/jquery-1.2.1.js">
  </script>
                                                                    Ready handler that
  <script type="text/javascript">                                 creates HTML element
   $(function(){
     $("<p>Hi there!</p>").insertAfter("#followMe");
   });
  </script>                                               Existing element
                                                            tobe followed
 </head>

 <body>
  <p id="followMe">Follow me!</p>
 </body>
</html>
Extending jQuery
                                          $.fn.disable means that we’re
                                          extending the $ wrapper with a function
                                          called disable.
$.fn.disable = function() {
  return this.each(function() {
    if (typeof this.disabled != "undefined") this.disabled = true;
  });
}




       So we can use .....


              $("form#myForm input.special").disable();

              $("form#myForm input.special").disable().addClass("moreSpecial");
Using jQuery in Conjunction with Other JavaScript
                        libraries

●   If use jQuery with other library such as
    Prototype, just call :

              jQuery.noConflict()
Q&A
Reference
●   Jquery in Action, Bear Bibeault, Yehuda Katz,
    Manning

Más contenido relacionado

La actualidad más candente

Kick start with j query
Kick start with j queryKick start with j query
Kick start with j query
Md. Ziaul Haq
 

La actualidad más candente (20)

AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Kick start with j query
Kick start with j queryKick start with j query
Kick start with j query
 
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
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
Lecture 6: Client Side Programming 2
Lecture 6: Client Side Programming 2Lecture 6: Client Side Programming 2
Lecture 6: Client Side Programming 2
 
Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1
 
How to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuery
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Going with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento GoGoing with style: Themes and apps for Magento Go
Going with style: Themes and apps for Magento Go
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Growing jQuery
Growing jQueryGrowing jQuery
Growing jQuery
 
Grails UI Primer
Grails UI PrimerGrails UI Primer
Grails UI Primer
 
Introduction to jQuery - The basics
Introduction to jQuery - The basicsIntroduction to jQuery - The basics
Introduction to jQuery - The basics
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
 

Destacado (6)

Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
 
jQuery presentation
jQuery presentationjQuery presentation
jQuery presentation
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 

Similar a Introducing jQuery

Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
azz71
 

Similar a Introducing jQuery (20)

J query training
J query trainingJ query training
J query training
 
Unit – II (1).pptx
Unit – II (1).pptxUnit – II (1).pptx
Unit – II (1).pptx
 
J query1
J query1J query1
J query1
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
jQuery
jQueryjQuery
jQuery
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
22 j query1
22 j query122 j query1
22 j query1
 
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
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
jQuery
jQueryjQuery
jQuery
 
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, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusionjQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusion
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
presentation_jquery_ppt.pptx
presentation_jquery_ppt.pptxpresentation_jquery_ppt.pptx
presentation_jquery_ppt.pptx
 
jQuery Basic API
jQuery Basic APIjQuery Basic API
jQuery Basic API
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And Tricks
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
JQuery
JQueryJQuery
JQuery
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 

Más de Wildan Maulana

Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Wildan Maulana
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
Wildan Maulana
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
Wildan Maulana
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
Wildan Maulana
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
Wildan Maulana
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Wildan Maulana
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Wildan Maulana
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Wildan Maulana
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
Wildan Maulana
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
Wildan Maulana
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
Wildan Maulana
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Wildan Maulana
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
Wildan Maulana
 

Más de Wildan Maulana (20)

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
 
Statistik Listrik
Statistik ListrikStatistik Listrik
Statistik Listrik
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : Equating
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Introducing jQuery

  • 1. #1 Day #1 Introducing jQuery Wildan Maulana wildan.m@openthinklabs.com http://workshop.openthinklabs.com
  • 2. Why we should use jQuery <script type="text/javascript"> $(function() { $("table tr:nth-child(even)").addClass("striped"); }); </script> The real power in this jQuery statement comes from the selector, an expression for identifying target elements on a page that allows us to easily identify and grab the elements we need;
  • 3. What Unobtrusive JavaScript means ● Unobtrusive JavaScript means behavior is separated from structure, think of it as MVC paradigm for JavaScript
  • 4. An Example of Unobtrusive JavaScript <button type="button" onclick="document.getElementById('xyz').style.color='red';"> Click Me </button> <head> <script type="text/javascript"> window.onload = function() { document.getElementById('testButton').onclick = makeItRed; }; function makeItRed() { document.getElementById('xyz').style.color = 'red'; } </script> </head> <body> <button type="button" id="testButton">Click Me</button> </body>
  • 5. The Fundamental Elements and concepts of jQuery ● At its core, jQuery focuses on retrieving elements from our HTML pages and per- forming operations upon them. ● Selector ..selector .., selector ..!
  • 6. The jQuery Wapper ● To collect a group of elements, we use the simple syntax : $(selector) or jQuery(selector) ● $("p a") means , retrieve a group of links nested inside a <p> element
  • 7. Query Chain ● $("div.notLongForThisWorld").fadeOut(); ● Query Chain : $("div.notLongForThisWorld").fadeOut().addClass("removed"); ● $("#someElement").html("I have added some text to an element"); same with $("#someElement")[0].innerHTML = "I have added some text to an element");
  • 8. Query Chain - cont ● $("div.fillMeIn").html("I have added some text to a group of nodes"); same with var elements = $("div.fillMeIn"); for(i=0;i<elements.length;i++) elements[i].innerHTML = "I have added some text to a group of nodes";
  • 9. Advanced Selector ● This selector is identical to the selector in CSS ● $("p:even"); means selects all even <p> elements ● $("tr:nth-child(1)"); means selects the first row of each table ● $("body > div"); means selects direct <div> children of <body>. ● $("a[href$=pdf]"); means selects link to PDF files ● $("body > div:has(a)") means selects direct <div> children of <body> - containing links Powerfull stuff right ?!! You can see for full list of selector here : http://docs.jquery.com/Selectors.
  • 10. About $ and jQuery() ● $ is alias of jQuery() ● $.trim(someString); is same with jQuery.trim(someString);
  • 11. The document ready handler ● To operate on a page jQuery have to wait until all DOM elements are fully loaded ● Traditionally we use the onload handler window.onload = function() { $("table tr:nth-child(even)").addClass("even"); }; But if we are using this method, browser will execute the load function after the DOM tree created and also waits until after all images and external resources are fully loaded and the page is displayed in the browser window
  • 12. A Better Approach ● A much better approach would be to wait only until the document structure is fully parsed and the browser has converted the HTML into its DOM tree form before executing the script to apply the rich behaviors. ● JQuery Way : $(document).ready(function() { $("table tr:nth-child(even)").addClass("even"); }); or using the shorthand : $(function() { $("table tr:nth-child(even)").addClass("even"); });
  • 13. Another use of $() Function ● Making DOM elements <html> <head> <title>Follow me!</title> <script type="text/javascript" src="../scripts/jquery-1.2.1.js"> </script> Ready handler that <script type="text/javascript"> creates HTML element $(function(){ $("<p>Hi there!</p>").insertAfter("#followMe"); }); </script> Existing element tobe followed </head> <body> <p id="followMe">Follow me!</p> </body> </html>
  • 14. Extending jQuery $.fn.disable means that we’re extending the $ wrapper with a function called disable. $.fn.disable = function() { return this.each(function() { if (typeof this.disabled != "undefined") this.disabled = true; }); } So we can use ..... $("form#myForm input.special").disable(); $("form#myForm input.special").disable().addClass("moreSpecial");
  • 15. Using jQuery in Conjunction with Other JavaScript libraries ● If use jQuery with other library such as Prototype, just call : jQuery.noConflict()
  • 16. Q&A
  • 17. Reference ● Jquery in Action, Bear Bibeault, Yehuda Katz, Manning