SlideShare a Scribd company logo
1 of 73
phpXperts - 09
What is jQuery

 Javascript Library
 Fast and concise
 Simplifies the interaction between HTML and JavaScript




                                           phpXperts - 09
Why jQuery?

 Lightweight : 19KB in size (Minified and Gzipped)
 CSS1 - 3 Complaint
 Cross Browser
     (IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome)




                                                 phpXperts - 09
Why jQuery?

 Lightweight : 19KB in size (Minified and Gzipped)
 CSS1 - 3 Complaint
 Cross Browser
     (IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome)



        Great Community                      Plugins

             Tutorials          TestCoverage

       Open (free) license                    Books



                                                 phpXperts - 09
A ajax and DOM manipulation example
if (!document.ELEMENT_NODE) { document.ELEMENT_NODE = 1;
   document.ATTRIBUTE_NODE = 2; document.TEXT_NODE = 3;
   document.CDATA_SECTION_NODE = 4; document.ENTITY_REFERENCE_NODE = 5;
   document.ENTITY_NODE = 6; document.PROCESSING_INSTRUCTION_NODE = 7;
   document.COMMENT_NODE = 8; document.DOCUMENT_NODE = 9;
   document.DOCUMENT_TYPE_NODE = 10; document.DOCUMENT_FRAGMENT_NODE = 11;
   document.NOTATION_NODE = 12; } document._importNode = function(node,
   allChildren) { switch (node.nodeType) { case document.ELEMENT_NODE: var
   newNode = document.createElement(node » .nodeName); /* does the node
   have any attributes to add? */ if (node.attributes && node.attributes »
   .length > 0) for (var i = 0; il = node.attributes.length; » i < il)
   newNode.setAttribute(node.attributes » .nodeName,
   node.getAttribute(node.attributes[i++] » .nodeName)); /* are we going
   after children too, and does » the node have any? */ if (allChildren &&
   node.childNodes && » node.childNodes.length > 0) for (var i = 0; il =
   node.childNodes.length; » i < il)
   newNode.appendChild(document._importNode » (node.childNodes[i++],
   allChildren)); return newNode; break; case document.TEXT_NODE: case
   document.CDATA_SECTION_NODE: case document.COMMENT_NODE: return
   document.createTextNode(node.nodeValue); break; } };


         http://www.alistapart.com/articles/crossbrowserscripting


                                                        phpXperts - 09
It’s just a single line in jQuery
$(“#content”).load(“page.html #content”);




                                    phpXperts - 09
Who’s using jQuery?




     http://docs.jquery.com/Sites_Using_jQuery


                                        phpXperts - 09
Dominating the world

Google trends comparison of last JS framework 12 months




http://www.google.com/trends?q=jQuery%2C+prototype%2C+yui%2C+dojo%2C+mootools&ctab=0&g
    eo=all&date=ytd&sort=0



                                                                phpXperts - 09
Let’s Start




                    Download jQuery
         http://docs.jquery.com/Downloading_jQuery




                                           phpXperts - 09
Embed in you page
<html>
  <head>
  <script src=“path/to/jquery-x.x.jsquot;></script>
  </head>
  <body> … </body>
</html>




                                      phpXperts - 09
Embed in you page
<html>
  <head>
  <script src=quot;path/to/jquery-x.x.jsquot;></script>
  <script>
     $(document).ready(function(){
           // Start here
     });
  </script>
  </head>
  <body> … </body>
</html>


                                      phpXperts - 09
jQuery philosophy
Find Some Elements
  {
 $(“div”).addClass(“xyz”);

                     }
                  Do something with them

         jQuery Object




                                    phpXperts - 09
A Basic Example



 <body>
    <div>
      <p>I m a paragraph 1</p>
      <p>I m a paragraph 2</p>
    </div>
    <p>I m another paragraph</p>
 </body>




                                   phpXperts - 09
A Basic Example
Select all paragraphs.
$(“p”)

 <body>
    <div>
      <p>I m a paragraph 1</p>
      <p>I m a paragraph 2</p>
    </div>
    <p>I m another paragraph</p>
 </body>




                                   phpXperts - 09
A Basic Example
Select all paragraphs. Add a class to them.
$(“p”).addClass(“red”);

 <body>
    <div>
       <p class=“red”>I m a paragraph -1</p>
       <p class=“red”>I m a paragraph -2</p>
    </div>
    <p class=“red”>I m another paragraph</p>
 </body>




                                              phpXperts - 09
Selector Basics

       Just pass a selector to $()

                      What is   selector?


       Use any CSS selector




                                     phpXperts - 09
Selector Basics
            Think about your simplest css file.

#header{
    margin : 0 auto;
}
div{
    margin : 0px;
    padding : 0px
}
ul.menu li{
    …..
}


                                           phpXperts - 09
Selector Basics
             The red colored items are selectors

#header{
    margin : 0 auto;
}
div{
    margin : 0px;
    padding : 0px
}
ul.menu li{
    …..
}


                                             phpXperts - 09
Selector Basics
                 Selecting using selectors
 Selecting By Id
     $(“#header”)




                                             phpXperts - 09
Selector Basics
                  Selecting using selectors
 Selecting By Id
     $(“#header”)
 Selecting By Class
     $(“.updated”)




                                              phpXperts - 09
Selector Basics
                   Selecting using selectors
 Selecting By Id
     $(“#header”)
 Selecting By Class
     $(“.updated”)
 Selecting by tag name
     $(“table”)




                                               phpXperts - 09
Selector Basics
                   Selecting using selectors
 Selecting By Id
     $(“#header”)
 Selecting By Class
     $(“.updated”)
 Selecting by tag name
     $(“table”)
 Combine them
     $(“table.user-list”)
     $(“#footer ul.menu li”)




                                               phpXperts - 09
Basic Selector Example
This is my page


<body>
  <div id=“header”>
      <span id=“logo”>Logo here…</span>
      <ul class=“menu”>
         <li>user name</li>
         …..
         <li>logout</li>
      </ul>
  </div>
   ……
</body>



                                          phpXperts - 09
Basic Selector Example
$(“#header”)


<body>
  <div id=“header”>
      <span id=“logo”>Logo here…</span>
      <ul class=“menu”>
         <li>user name</li>
         …..
         <li>logout</li>
      </ul>
  </div>
  ……
</body>



                                          phpXperts - 09
Basic Selector Example
$(“ul.menu”)


<body>
  <div id=“header”>
      <span id=“logo”>Logo here…</span>
      <ul class=“menu”>
         <li>user name</li>
         …..
         <li>logout</li>
      </ul>
  </div>
  ……
</body>



                                          phpXperts - 09
Basic Selector Example
$(“ul.menu li”)


<body>
  <div id=“header”>
      <span id=“logo”>Logo here…</span>
      <ul class=“menu”>
         <li>user name</li>
         …..
         <li>logout</li>
      </ul>
  </div>
  ……
</body>



                                          phpXperts - 09
Using filters for selecting

  Basic Filters
     :first, :last, :even, :odd, …...




                                         phpXperts - 09
Basic Filters Example

Student list table. Lets make it zebra.




        Name             Class            Roll No.       Comment
Raju                      XII                2       Good
Masud                      IX                1       Good
Apu                       XII                3
Mizan                     XII                5
Karim                      VI                2       Satisfactory




                                                     phpXperts - 09
Basic Filters Example

$(“#students tr:even”).css(“background-color”, “#dde”)




        Name       Class         Roll No.       Comment
Raju                XII             2       Good
Masud               IX              1       Good
Apu                 XII             3
Mizan               XII             5
Karim               VI              2       Satisfactory




                                            phpXperts - 09
Using filters for selecting

  Basic Filters
     :first, :last, :even, :odd, …...
  Content Filters:
     :empty , :contains(text), :has(selector), …..




                                                      phpXperts - 09
Content Filters Example

$(“#students tr:even”).css(“background-color”, “#dde”);
$(“#students td.comment:empty”).text(“No Comment”);




        Name       Class         Roll No.       Comment
Raju                XII             2       Good
Masud               IX              1       Good
Apu                 XII             3       No Comment
Mizan               XII             5       No Comment
Karim               VI              2       Satisfactory




                                            phpXperts - 09
Using filters for selecting

  Basic Filters
     :first, :last, :even, :odd, …...
  Content Filters:
     :empty , :contains(text), :has(selector), …..
  Attribute Filters:
     [attribute], [attribute=value], [attribute!=value], …..




                                                      phpXperts - 09
Attribute Filters Example

$(“#students tr:even”).css(“background-color”, “#dde”);
$(“#students td.comment:empty”).text(“No Comment”);
$(“#students td[align=„center']quot;).addClass(“ocean”);




        Name       Class         Roll No.       Comment
Raju                XII             2       Good
Masud               IX              1       Good
Apu                 XII             3       No Comment
Mizan               XII             5       No Comment
Karim               VI              2       Satisfactory




                                            phpXperts - 09
Using filters for selecting

  Basic Filters
     :first, :last, :even, :odd, …...
  Content Filters:
     :empty , :contains(text), :has(selector), …..
  Attribute Filters:
     [attribute], [attribute=value], [attribute!=value], …..
  Forms
     :input, :text, :submit, :password, …..
     :enabled, :disabled, :checked, …..




                                                      phpXperts - 09
Forms Selector Example

$(quot;:submitquot;).click(function(e){ … });

$(quot;input:disabledquot;).val(“You cannot change mequot;);

$(“#form-id input:checked”).addClass(“selected”);




                                           phpXperts - 09
Now we can Select
Let’s perform some action




                            phpXperts - 09
jQuery Methods

 DOM Manipulation
     before(), after(), append(), appendTo(), …..




                                                     phpXperts - 09
Dom Manipulation Example

Move all paragraphs in div with id “contents”

$(“p”)


<body>
  <h1>jQuery</h1>
  <p>jQuery is good</p>
  <p>jQuery is better</p>
  <div id=“contents”></div>
  <p>jQuery is the best</p>

</body>




                                                phpXperts - 09
Dom Manipulation Example

Move all paragraphs in div with id “contents”

$(“p”).appendTo(“#contents”);


<body>
  <h1>jQuery</h1>
  <div id=“contents”>
      <p>jQuery is good</p>
      <p>jQuery is better</p>
      <p>jQuery is the best</p>
  </div>
</body>




                                                phpXperts - 09
Dom Manipulation Example

Move all paragraphs in div with id “contents”

$(“p”).appendTo(“#contents”);
$(“h1”).append(“ Dom Manipulation”);

<body>
  <h1>jQuery Dom Manipulation</h1>
  <div id=“contents”>
      <p>jQuery is good</p>
      <p>jQuery is better</p>
      <p>jQuery is the best</p>
  </div>
</body>




                                                phpXperts - 09
jQuery Methods

 DOM Manipulation
     before(), after(), append(), appendTo(), …..
 Attributes
     css(), addClass(), attr(), html(), val(), …..




                                                      phpXperts - 09
Attributes Example

Make the texts of last paragraph bold

$(“#contents p:last”).css(“color”, “green”);

<body>
  <h1>jQuery Dom Manipulation</h1>
  <div id=“contents”>
      <p >jQuery is good</p>
      <p>jQuery is better</p>
      <p style=“color:green”>jQuery is the best</p>
  </div>
</body>




                                        phpXperts - 09
More Attributes Example

                     Setting

 $(“img.logo”).attr(“align”, “left”);
 $(“p.copyright”).html(“&copy; 2009 ajaxray”);
 $(“input#name”).val(“Spiderman”);




                                        phpXperts - 09
More Attributes Example

                     Setting

 $(“img.logo”).attr(“align”, “left”);
 $(“p.copyright”).html(“&copy; 2009 ajaxray”);
 $(“input#name”).val(“Spiderman”);

                     Getting

 var allignment = $(“img.logo”).attr(“align”);
 var copyright = $(“p.copyright”).html();
 var username = $(“input#name”).val();




                                         phpXperts - 09
jQuery Methods

 DOM Manipulation
     before(), after(), append(), appendTo(), …..
 Attributes
     css(), addClass(), attr(), html(), val(), …..
 Events
     click(), bind(), unbind(), live(), …..




                                                      phpXperts - 09
Event Example

Start when DOM is ready

$(document).ready(function(){

  $(selector).eventName(function(){…});

});




                                          phpXperts - 09
Event Example
Bind all interactions on events.

$(document).ready(function(){

  $(“#message”).click(function(){
      $(this).hide();
  })

});

<span id=“message” onclick=“…”> blah blah </span>




                                       phpXperts - 09
Event Example
You can fire events manually.

$(document).ready(function(){

  $(“span#message”).click(function(){
      $(this).hide();
  })

  $(“#form-id:reset”).click();

});




                                        phpXperts - 09
jQuery Methods

 DOM Manipulation
     before(), after(), append(), appendTo(), …..
 Attributes
     css(), addClass(), attr(), html(), val(), …..
 Events
     click(), bind(), unbind(), live(), …..
 Effects
     hide(), fadeOut(), toggle(), animate(), …..




                                                      phpXperts - 09
Effects Example

When “show-cart” link clicked, slide up/down “cart” div.

$(“a#show-cart”).click(function(){
   $(“#cart”).slideToggle(“slow”);
})




                                                      phpXperts - 09
Effects Example

Build your custom animation

$(“a#show-cart”).click(function(){
   $(“#cart”).slideToggle(“slow”);
})

$(quot;#showdownquot;).click(function(){
   $(quot;#my-divquot;).animate({
      width: quot;70%quot;,
      opacity: 0.4,
      fontSize: quot;3em“
   }, 1200 );
});




                                     phpXperts - 09
jQuery Methods

 DOM Manipulation
     before(), after(), append(), appendTo(), …..
 Attributes
     css(), addClass(), attr(), html(), val(), …..
 Events
     click(), bind(), unbind(), live(), …..
 Effects
     hide(), fadeOut(), toggle(), animate(), …..
 Ajax
     load(), get(), ajax(), getJSON(), …..




                                                      phpXperts - 09
Ajax Examples

Load a page in a container

$(“#comments”).load(“/get_comments.php”);

$(“#comments”).load(“/get_comments.php”, {max : 5});




                                       phpXperts - 09
Ajax Examples

Send ajax request with data

$.get(“/edit_comment.phpquot;,
      {id: 102, comment: “I m editedquot;}
);




                                         phpXperts - 09
Ajax Examples

You can send serialized form as data

$.get(“/edit_comment.phpquot;,
      $(“#edit-comment”).serialize()
);


id=102&comment=I+m+edited




                                       phpXperts - 09
Ajax Examples

Set a callback function for handling response data

$.get(“edit_comment.phpquot;,
      $(“form#cmm-edit”).serialize(),
      function(data){
         if(data == “success”)
            alert(“Comment Edited!”);
      }
);




                                              phpXperts - 09
Chaining Methods

 Most jQuery methods return jQuery object
 You can chain them together




                                            phpXperts - 09
Chaining Methods

  Most jQuery methods return jQuery object
  You can chain them together


$(“#deleted”).addClass(“red”).fadeOut(“slow”);
$(“:button”).val(“Click Me”).click(function(){…})




                                             phpXperts - 09
Chaining Methods

  Most jQuery methods return jQuery object
  You can chain them together


$(“#deleted”).addClass(“red”).fadeOut(“slow”);
$(“:button”).val(“Click Me”).click(function(){…})


This will not work -


$(“:button”).val().click(function(){…})


                       This method will return string



                                                        phpXperts - 09
jQuery Plugins
jQuery is extensible.




                        phpXperts - 09
jQuery Plugins

                    jQuery lightBox




    http://leandrovieira.com/projects/jquery/lightbox/




                                            phpXperts - 09
jQuery Plugins

                    Slider Plugins




   http://www.hieu.co.uk/blog/index.php/imageswitch/
        http://medienfreunde.com/lab/innerfade/


                                         phpXperts - 09
And thousands of more…
http://plugins.jquery.com/




                             phpXperts - 09
jQuery UI
Build highly interactive web applications




                                            phpXperts - 09
jQuery UI – Interactions
      (Draggale, Droppable, Resizable, Selectable, Sortable)




                                                    phpXperts - 09
jQuery UI – Sortable Example


$(quot;#itemsquot;).sortable();




                               phpXperts - 09
jQuery UI – Widgets
     (Accordion, Datepicker, Dialog, Progressbar, Slider, Tabs)




                                                     phpXperts - 09
jQuery UI – Datepicker Example

$(quot;#datequot;).datepicker();




                                 phpXperts - 09
Which one will match your site?




                                  phpXperts - 09
Designing a jQuery UI theme - Themeroller




         http://ui.jquery.com/themeroller

                                            phpXperts - 09
Anis uddin Ahmad
Sr. Software Engineer
Right Brain Solution Ltd.
http://ajaxray.com




                            phpXperts - 09
Questions?




             phpXperts - 09
THANK YOU




            phpXperts - 09

More Related Content

What's hot

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 BasicsEPAM Systems
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuerymanugoel2003
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginnersSingsys Pte Ltd
 
Document Object Model
Document Object ModelDocument Object Model
Document Object ModelMayur Mudgal
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom ManipulationMohammed Arif
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tagsKainat Ilyas
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 

What's hot (20)

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 PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Javascript
JavascriptJavascript
Javascript
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
jQuery
jQueryjQuery
jQuery
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
jQuery
jQueryjQuery
jQuery
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
Javascript
JavascriptJavascript
Javascript
 
Dom
Dom Dom
Dom
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 

Similar to jQuery from the very beginning

Jquery presentation
Jquery presentationJquery presentation
Jquery presentationguest5d87aa6
 
Jquery tutorial
Jquery tutorialJquery tutorial
Jquery tutorialBui Kiet
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentationguest5d87aa6
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
Zend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample QuestionsZend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample QuestionsJagat Kothari
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Michael Wales
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010singingfish
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 

Similar to jQuery from the very beginning (20)

Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Jquery tutorial
Jquery tutorialJquery tutorial
Jquery tutorial
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Zend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample QuestionsZend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample Questions
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Api Design
Api DesignApi Design
Api Design
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
前端概述
前端概述前端概述
前端概述
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
Smarty
SmartySmarty
Smarty
 
Smarty
SmartySmarty
Smarty
 

More from Anis Ahmad

Testing in Laravel Framework
Testing in Laravel FrameworkTesting in Laravel Framework
Testing in Laravel FrameworkAnis Ahmad
 
Writing Sensible Code
Writing Sensible CodeWriting Sensible Code
Writing Sensible CodeAnis Ahmad
 
Revisiting SOLID Principles
Revisiting  SOLID Principles Revisiting  SOLID Principles
Revisiting SOLID Principles Anis Ahmad
 
VCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopVCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopAnis Ahmad
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript ApplicationAnis Ahmad
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with RubyAnis Ahmad
 
Caching basics in PHP
Caching basics in PHPCaching basics in PHP
Caching basics in PHPAnis Ahmad
 
Freelancing; an alternate career
Freelancing; an alternate careerFreelancing; an alternate career
Freelancing; an alternate careerAnis Ahmad
 

More from Anis Ahmad (8)

Testing in Laravel Framework
Testing in Laravel FrameworkTesting in Laravel Framework
Testing in Laravel Framework
 
Writing Sensible Code
Writing Sensible CodeWriting Sensible Code
Writing Sensible Code
 
Revisiting SOLID Principles
Revisiting  SOLID Principles Revisiting  SOLID Principles
Revisiting SOLID Principles
 
VCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT WorkshopVCS for Teamwork - GIT Workshop
VCS for Teamwork - GIT Workshop
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
Caching basics in PHP
Caching basics in PHPCaching basics in PHP
Caching basics in PHP
 
Freelancing; an alternate career
Freelancing; an alternate careerFreelancing; an alternate career
Freelancing; an alternate career
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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 WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

jQuery from the very beginning

  • 2. What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript phpXperts - 09
  • 3. Why jQuery? Lightweight : 19KB in size (Minified and Gzipped) CSS1 - 3 Complaint Cross Browser  (IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome) phpXperts - 09
  • 4. Why jQuery? Lightweight : 19KB in size (Minified and Gzipped) CSS1 - 3 Complaint Cross Browser  (IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome) Great Community Plugins Tutorials TestCoverage Open (free) license Books phpXperts - 09
  • 5. A ajax and DOM manipulation example if (!document.ELEMENT_NODE) { document.ELEMENT_NODE = 1; document.ATTRIBUTE_NODE = 2; document.TEXT_NODE = 3; document.CDATA_SECTION_NODE = 4; document.ENTITY_REFERENCE_NODE = 5; document.ENTITY_NODE = 6; document.PROCESSING_INSTRUCTION_NODE = 7; document.COMMENT_NODE = 8; document.DOCUMENT_NODE = 9; document.DOCUMENT_TYPE_NODE = 10; document.DOCUMENT_FRAGMENT_NODE = 11; document.NOTATION_NODE = 12; } document._importNode = function(node, allChildren) { switch (node.nodeType) { case document.ELEMENT_NODE: var newNode = document.createElement(node » .nodeName); /* does the node have any attributes to add? */ if (node.attributes && node.attributes » .length > 0) for (var i = 0; il = node.attributes.length; » i < il) newNode.setAttribute(node.attributes » .nodeName, node.getAttribute(node.attributes[i++] » .nodeName)); /* are we going after children too, and does » the node have any? */ if (allChildren && node.childNodes && » node.childNodes.length > 0) for (var i = 0; il = node.childNodes.length; » i < il) newNode.appendChild(document._importNode » (node.childNodes[i++], allChildren)); return newNode; break; case document.TEXT_NODE: case document.CDATA_SECTION_NODE: case document.COMMENT_NODE: return document.createTextNode(node.nodeValue); break; } }; http://www.alistapart.com/articles/crossbrowserscripting phpXperts - 09
  • 6. It’s just a single line in jQuery $(“#content”).load(“page.html #content”); phpXperts - 09
  • 7. Who’s using jQuery? http://docs.jquery.com/Sites_Using_jQuery phpXperts - 09
  • 8. Dominating the world Google trends comparison of last JS framework 12 months http://www.google.com/trends?q=jQuery%2C+prototype%2C+yui%2C+dojo%2C+mootools&ctab=0&g eo=all&date=ytd&sort=0 phpXperts - 09
  • 9. Let’s Start Download jQuery http://docs.jquery.com/Downloading_jQuery phpXperts - 09
  • 10. Embed in you page <html> <head> <script src=“path/to/jquery-x.x.jsquot;></script> </head> <body> … </body> </html> phpXperts - 09
  • 11. Embed in you page <html> <head> <script src=quot;path/to/jquery-x.x.jsquot;></script> <script> $(document).ready(function(){ // Start here }); </script> </head> <body> … </body> </html> phpXperts - 09
  • 12. jQuery philosophy Find Some Elements { $(“div”).addClass(“xyz”); } Do something with them jQuery Object phpXperts - 09
  • 13. A Basic Example <body> <div> <p>I m a paragraph 1</p> <p>I m a paragraph 2</p> </div> <p>I m another paragraph</p> </body> phpXperts - 09
  • 14. A Basic Example Select all paragraphs. $(“p”) <body> <div> <p>I m a paragraph 1</p> <p>I m a paragraph 2</p> </div> <p>I m another paragraph</p> </body> phpXperts - 09
  • 15. A Basic Example Select all paragraphs. Add a class to them. $(“p”).addClass(“red”); <body> <div> <p class=“red”>I m a paragraph -1</p> <p class=“red”>I m a paragraph -2</p> </div> <p class=“red”>I m another paragraph</p> </body> phpXperts - 09
  • 16. Selector Basics Just pass a selector to $() What is selector? Use any CSS selector phpXperts - 09
  • 17. Selector Basics Think about your simplest css file. #header{ margin : 0 auto; } div{ margin : 0px; padding : 0px } ul.menu li{ ….. } phpXperts - 09
  • 18. Selector Basics The red colored items are selectors #header{ margin : 0 auto; } div{ margin : 0px; padding : 0px } ul.menu li{ ….. } phpXperts - 09
  • 19. Selector Basics Selecting using selectors Selecting By Id  $(“#header”) phpXperts - 09
  • 20. Selector Basics Selecting using selectors Selecting By Id  $(“#header”) Selecting By Class  $(“.updated”) phpXperts - 09
  • 21. Selector Basics Selecting using selectors Selecting By Id  $(“#header”) Selecting By Class  $(“.updated”) Selecting by tag name  $(“table”) phpXperts - 09
  • 22. Selector Basics Selecting using selectors Selecting By Id  $(“#header”) Selecting By Class  $(“.updated”) Selecting by tag name  $(“table”) Combine them  $(“table.user-list”)  $(“#footer ul.menu li”) phpXperts - 09
  • 23. Basic Selector Example This is my page <body> <div id=“header”> <span id=“logo”>Logo here…</span> <ul class=“menu”> <li>user name</li> ….. <li>logout</li> </ul> </div> …… </body> phpXperts - 09
  • 24. Basic Selector Example $(“#header”) <body> <div id=“header”> <span id=“logo”>Logo here…</span> <ul class=“menu”> <li>user name</li> ….. <li>logout</li> </ul> </div> …… </body> phpXperts - 09
  • 25. Basic Selector Example $(“ul.menu”) <body> <div id=“header”> <span id=“logo”>Logo here…</span> <ul class=“menu”> <li>user name</li> ….. <li>logout</li> </ul> </div> …… </body> phpXperts - 09
  • 26. Basic Selector Example $(“ul.menu li”) <body> <div id=“header”> <span id=“logo”>Logo here…</span> <ul class=“menu”> <li>user name</li> ….. <li>logout</li> </ul> </div> …… </body> phpXperts - 09
  • 27. Using filters for selecting Basic Filters  :first, :last, :even, :odd, …... phpXperts - 09
  • 28. Basic Filters Example Student list table. Lets make it zebra. Name Class Roll No. Comment Raju XII 2 Good Masud IX 1 Good Apu XII 3 Mizan XII 5 Karim VI 2 Satisfactory phpXperts - 09
  • 29. Basic Filters Example $(“#students tr:even”).css(“background-color”, “#dde”) Name Class Roll No. Comment Raju XII 2 Good Masud IX 1 Good Apu XII 3 Mizan XII 5 Karim VI 2 Satisfactory phpXperts - 09
  • 30. Using filters for selecting Basic Filters  :first, :last, :even, :odd, …... Content Filters:  :empty , :contains(text), :has(selector), ….. phpXperts - 09
  • 31. Content Filters Example $(“#students tr:even”).css(“background-color”, “#dde”); $(“#students td.comment:empty”).text(“No Comment”); Name Class Roll No. Comment Raju XII 2 Good Masud IX 1 Good Apu XII 3 No Comment Mizan XII 5 No Comment Karim VI 2 Satisfactory phpXperts - 09
  • 32. Using filters for selecting Basic Filters  :first, :last, :even, :odd, …... Content Filters:  :empty , :contains(text), :has(selector), ….. Attribute Filters:  [attribute], [attribute=value], [attribute!=value], ….. phpXperts - 09
  • 33. Attribute Filters Example $(“#students tr:even”).css(“background-color”, “#dde”); $(“#students td.comment:empty”).text(“No Comment”); $(“#students td[align=„center']quot;).addClass(“ocean”); Name Class Roll No. Comment Raju XII 2 Good Masud IX 1 Good Apu XII 3 No Comment Mizan XII 5 No Comment Karim VI 2 Satisfactory phpXperts - 09
  • 34. Using filters for selecting Basic Filters  :first, :last, :even, :odd, …... Content Filters:  :empty , :contains(text), :has(selector), ….. Attribute Filters:  [attribute], [attribute=value], [attribute!=value], ….. Forms  :input, :text, :submit, :password, …..  :enabled, :disabled, :checked, ….. phpXperts - 09
  • 35. Forms Selector Example $(quot;:submitquot;).click(function(e){ … }); $(quot;input:disabledquot;).val(“You cannot change mequot;); $(“#form-id input:checked”).addClass(“selected”); phpXperts - 09
  • 36. Now we can Select Let’s perform some action phpXperts - 09
  • 37. jQuery Methods DOM Manipulation  before(), after(), append(), appendTo(), ….. phpXperts - 09
  • 38. Dom Manipulation Example Move all paragraphs in div with id “contents” $(“p”) <body> <h1>jQuery</h1> <p>jQuery is good</p> <p>jQuery is better</p> <div id=“contents”></div> <p>jQuery is the best</p> </body> phpXperts - 09
  • 39. Dom Manipulation Example Move all paragraphs in div with id “contents” $(“p”).appendTo(“#contents”); <body> <h1>jQuery</h1> <div id=“contents”> <p>jQuery is good</p> <p>jQuery is better</p> <p>jQuery is the best</p> </div> </body> phpXperts - 09
  • 40. Dom Manipulation Example Move all paragraphs in div with id “contents” $(“p”).appendTo(“#contents”); $(“h1”).append(“ Dom Manipulation”); <body> <h1>jQuery Dom Manipulation</h1> <div id=“contents”> <p>jQuery is good</p> <p>jQuery is better</p> <p>jQuery is the best</p> </div> </body> phpXperts - 09
  • 41. jQuery Methods DOM Manipulation  before(), after(), append(), appendTo(), ….. Attributes  css(), addClass(), attr(), html(), val(), ….. phpXperts - 09
  • 42. Attributes Example Make the texts of last paragraph bold $(“#contents p:last”).css(“color”, “green”); <body> <h1>jQuery Dom Manipulation</h1> <div id=“contents”> <p >jQuery is good</p> <p>jQuery is better</p> <p style=“color:green”>jQuery is the best</p> </div> </body> phpXperts - 09
  • 43. More Attributes Example Setting $(“img.logo”).attr(“align”, “left”); $(“p.copyright”).html(“&copy; 2009 ajaxray”); $(“input#name”).val(“Spiderman”); phpXperts - 09
  • 44. More Attributes Example Setting $(“img.logo”).attr(“align”, “left”); $(“p.copyright”).html(“&copy; 2009 ajaxray”); $(“input#name”).val(“Spiderman”); Getting var allignment = $(“img.logo”).attr(“align”); var copyright = $(“p.copyright”).html(); var username = $(“input#name”).val(); phpXperts - 09
  • 45. jQuery Methods DOM Manipulation  before(), after(), append(), appendTo(), ….. Attributes  css(), addClass(), attr(), html(), val(), ….. Events  click(), bind(), unbind(), live(), ….. phpXperts - 09
  • 46. Event Example Start when DOM is ready $(document).ready(function(){ $(selector).eventName(function(){…}); }); phpXperts - 09
  • 47. Event Example Bind all interactions on events. $(document).ready(function(){ $(“#message”).click(function(){ $(this).hide(); }) }); <span id=“message” onclick=“…”> blah blah </span> phpXperts - 09
  • 48. Event Example You can fire events manually. $(document).ready(function(){ $(“span#message”).click(function(){ $(this).hide(); }) $(“#form-id:reset”).click(); }); phpXperts - 09
  • 49. jQuery Methods DOM Manipulation  before(), after(), append(), appendTo(), ….. Attributes  css(), addClass(), attr(), html(), val(), ….. Events  click(), bind(), unbind(), live(), ….. Effects  hide(), fadeOut(), toggle(), animate(), ….. phpXperts - 09
  • 50. Effects Example When “show-cart” link clicked, slide up/down “cart” div. $(“a#show-cart”).click(function(){ $(“#cart”).slideToggle(“slow”); }) phpXperts - 09
  • 51. Effects Example Build your custom animation $(“a#show-cart”).click(function(){ $(“#cart”).slideToggle(“slow”); }) $(quot;#showdownquot;).click(function(){ $(quot;#my-divquot;).animate({ width: quot;70%quot;, opacity: 0.4, fontSize: quot;3em“ }, 1200 ); }); phpXperts - 09
  • 52. jQuery Methods DOM Manipulation  before(), after(), append(), appendTo(), ….. Attributes  css(), addClass(), attr(), html(), val(), ….. Events  click(), bind(), unbind(), live(), ….. Effects  hide(), fadeOut(), toggle(), animate(), ….. Ajax  load(), get(), ajax(), getJSON(), ….. phpXperts - 09
  • 53. Ajax Examples Load a page in a container $(“#comments”).load(“/get_comments.php”); $(“#comments”).load(“/get_comments.php”, {max : 5}); phpXperts - 09
  • 54. Ajax Examples Send ajax request with data $.get(“/edit_comment.phpquot;, {id: 102, comment: “I m editedquot;} ); phpXperts - 09
  • 55. Ajax Examples You can send serialized form as data $.get(“/edit_comment.phpquot;, $(“#edit-comment”).serialize() ); id=102&comment=I+m+edited phpXperts - 09
  • 56. Ajax Examples Set a callback function for handling response data $.get(“edit_comment.phpquot;, $(“form#cmm-edit”).serialize(), function(data){ if(data == “success”) alert(“Comment Edited!”); } ); phpXperts - 09
  • 57. Chaining Methods Most jQuery methods return jQuery object You can chain them together phpXperts - 09
  • 58. Chaining Methods Most jQuery methods return jQuery object You can chain them together $(“#deleted”).addClass(“red”).fadeOut(“slow”); $(“:button”).val(“Click Me”).click(function(){…}) phpXperts - 09
  • 59. Chaining Methods Most jQuery methods return jQuery object You can chain them together $(“#deleted”).addClass(“red”).fadeOut(“slow”); $(“:button”).val(“Click Me”).click(function(){…}) This will not work - $(“:button”).val().click(function(){…}) This method will return string phpXperts - 09
  • 60. jQuery Plugins jQuery is extensible. phpXperts - 09
  • 61. jQuery Plugins jQuery lightBox http://leandrovieira.com/projects/jquery/lightbox/ phpXperts - 09
  • 62. jQuery Plugins Slider Plugins http://www.hieu.co.uk/blog/index.php/imageswitch/ http://medienfreunde.com/lab/innerfade/ phpXperts - 09
  • 63. And thousands of more… http://plugins.jquery.com/ phpXperts - 09
  • 64. jQuery UI Build highly interactive web applications phpXperts - 09
  • 65. jQuery UI – Interactions (Draggale, Droppable, Resizable, Selectable, Sortable) phpXperts - 09
  • 66. jQuery UI – Sortable Example $(quot;#itemsquot;).sortable(); phpXperts - 09
  • 67. jQuery UI – Widgets (Accordion, Datepicker, Dialog, Progressbar, Slider, Tabs) phpXperts - 09
  • 68. jQuery UI – Datepicker Example $(quot;#datequot;).datepicker(); phpXperts - 09
  • 69. Which one will match your site? phpXperts - 09
  • 70. Designing a jQuery UI theme - Themeroller http://ui.jquery.com/themeroller phpXperts - 09
  • 71. Anis uddin Ahmad Sr. Software Engineer Right Brain Solution Ltd. http://ajaxray.com phpXperts - 09
  • 72. Questions? phpXperts - 09
  • 73. THANK YOU phpXperts - 09