SlideShare a Scribd company logo
1 of 136
Download to read offline
Overview

• Who, what and why of jQuery
• 5 core jQuery concepts
• Overview of jQuery API
• Building a plugin in 6 steps
• jQuery News
Who's using jQuery
Who's using jQuery
Who's using jQuery

    reddit.com         whitehouse.gov              overstock.com
     espn.com          microsoft.com                  time.com
     ibm.com            amazon.com                 capitalone.com
stackoverflow.com         netflix.com                wordpress.com
     boxee.tv             bing.com                     dell.com
       bit.ly           monster.com                  twitter.com
   twitpic.com             tv.com                       w3.org

           http://trends.builtwith.com/javascript/jquery
Who's using jQuery

reddit.com           whitehouse.gov              overstock.com
 espn.com            microsoft.com                  time.com
 ibm.com              amazon.com                 capitalone.com
        stackoverflow.com
                       netflix.com                wordpress.com
 boxee.tv               bing.com                     dell.com
   bit.ly             monster.com                  twitter.com
twitpic.com              tv.com                       w3.org

         http://trends.builtwith.com/javascript/jquery
What exactly is jQuery
jQuery is a JavaScript library!


• Dealing with the DOM changing, etc)
  (e.g. selecting, creating, traversing,

• JavaScript Events
• Animations
• Ajax interactions
What does that mean?
It means no more of this
var tables = document.getElementsByTagName('table');
for (var t = 0; t < tables.length; t++) {
!   var rows = tables[t].getElementsByTagName('tr');
!   for (var i = 1; i < rows.length; i += 2) {
        if (!/(^|s)odd(s|$)/.test(rows[i].className)) {
            rows[i].className += ' odd';
        }
    }
}
jQuery simpli es


jQuery('table tr:nth-child(odd)').addClass('odd');
jQuery simpli es

  jQuery function

jQuery('table tr:nth-child(odd)').addClass('odd');
jQuery simpli es

  jQuery function

jQuery('table tr:nth-child(odd)').addClass('odd');


                CSS expression
jQuery simpli es

  jQuery function             jQuery method
jQuery('table tr:nth-child(odd)').addClass('odd');


                CSS expression
jQuery simpli es


jQuery('table tr:nth-child(odd)').addClass('odd');
It really is the

Write less, do more
  JavaScript library!
Why use jQuery
•   Helps us to simplify and speed up web development

•   Allows us to avoid common headaches associated
    with browser development

•   Provides a large pool of plugins

•   Large and active community

•   Tested on 50 browsers, 11 platforms

•   For both coder and designer (we don't discriminate)
Why use jQuery
•   Helps us to simplify and speed up web development

•   Allows us to avoid common headaches associated
    with browser development

•   Provides a large pool of plugins

•   Large and active community

•   Tested on 50 browsers, 11 platforms

•   For both coder and designer (we don't discriminate)
Help!
APIs            Blogs, tutorials, screencasts,
 docs.jquery.com        plugins, development sprints
  api.jquery.com
 visualjquery.com
                                          Google Groups
                                              jquery-en
  Twitter                                    jquery-dev
 @jquery              Help!                 jquery-ui-en
@jquerysites                               jquery-ui-dev
 @jqueryui                                  jquery-a11y
                      IRC channel
               irc.freenode.net/#jquery
APIs         Blogs, tutorials, screencasts,
 docs.jquery.com     plugins, development sprints
  api.jquery.com
 visualjquery.com
                                       Google Groups
                                           jquery-en
  Twitter                                 jquery-dev
 @jquery            Help!                jquery-ui-en
@jquerysites                            jquery-ui-dev
 @jqueryui                               jquery-a11y
                   IRC channel
            irc.freenode.net/#jquery
Concept 1:
knowing the jQuery
 parameter types
• CSS selectors & custom CSS expressions
• HTML
• DOM elements
• A function (shortcut for DOM ready)
jQuery(‘div’) & jQuery(‘:first’)


   • CSS selectors & custom CSS expressions
   • HTML
   • DOM elements
   • A function (shortcut for DOM ready)
jQuery(‘<li><a href=”#”>link</a></li>’)


    • CSS selectors jQuery(‘:first’)
    jQuery(‘div’) &
                    & custom CSS expressions


    • HTML
    • DOM elements
    • A function (shortcut for DOM ready)
jQuery(document) or jQuery(document.createElement(‘a’))




      • CSS selectors jQuery(‘:first’)
      jQuery(‘div’) &
                      & custom CSS expressions


      • HTML
      jQuery(‘<li><a href=”#”>link</a></li>’)


      • DOM elements
      • A function (shortcut for DOM ready)
jQuery(function(){}) =
jQuery(document).ready(function(){})

   • CSS selectors jQuery(‘:first’)
   jQuery(‘div’) &
                   & custom CSS expressions


   • HTML
   jQuery(‘<li><a href=”#”>link</a></li>’)


   • DOM elements
   jQuery(document) or jQuery(document.createElement(‘a’))


   • A function (shortcut for DOM ready)
• CSS selectors jQuery(‘:first’)
jQuery(‘div’) &
                & custom CSS expressions


• HTML
jQuery(‘<li><a href=”#”>link</a></li>’)


• DOM elements
jQuery(document) or jQuery(document.createElement(‘a’))


• A function (shortcut for DOM ready)
       jQuery(function(){}) =
jQuery(document).ready(function(){})
Concept 2:
nd something,
do something
<!DOCTYPE html>
<html>
<body>
  <ul>
    <li><a>home</a></li>
    <li><a>about</a></li>
  </ul>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul>
    <li><a>home</a></li>
    <li><a>about</a></li>
  </ul>
<script src="jquery.js"></script>
<script>
  jQuery('ul');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id="nav">
    <li><a>home</a></li>
    <li><a>about</a></li>
  </ul>
<script src="jquery.js"></script>
<script>
  jQuery('ul').attr('id', 'nav');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id="nav">
    <li><a>home</a></li>
    <li><a>about</a></li>
  </ul>
<script src="jquery.js"></script>
<script>
  jQuery('#nav a');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id="nav">
    <li><a href=”/home”>home</a></li>
    <li><a href=”/about”>about</a></li>
  </ul>
<script src="jquery.js"></script>
<script>
  jQuery('#nav a').each(function(){
    jQuery(this).attr(‘href’,
   ➥ ‘/’ + jQuery(this).text());
  });
</script>
</body>
</html>
Concept 3:
create something,
  do something
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
  </ul>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘<li>home</li>’);
  jQuery(‘<li>about</li>’);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘<li>home</li>’)
➥.wrapInner(‘<a/>’);
  jQuery(‘<li>about</li>’)
➥.wrapInner(‘<a/>’);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li><a>home</a></li>
    <li><a>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘<li>home</li>’)
➥.wrapInner(‘<a/>’).appendTo(‘#nav’);
  jQuery(‘<li>about</li>’)
➥.wrapInner(‘<a/>’).appendTo(‘#nav’);
</script>
</body>
</html>
Concept 4:
chaining & operating
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘ul’).attr(‘id’, ‘nav’);
  jQuery(‘#nav li’).addClass(‘item’);
  jQuery(‘#nav a’).each(function () {
    jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
  });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
    1
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
1 jQuery(‘ul’).attr(‘id’, ‘nav’);
  jQuery(‘#nav li’).addClass(‘item’);
  jQuery(‘#nav a’).each(function () {
    jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
  });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
    1
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>      2
<script src=”jquery.js”></script>
<script>
1 jQuery(‘ul’).attr(‘id’, ‘nav’);
                                    2
  jQuery(‘#nav li’).addClass(‘item’);
  jQuery(‘#nav a’).each(function () {
    jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
  });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
    1
<body>
  <ul id='nav'>                3
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>      2
<script src=”jquery.js”></script>
<script>
1 jQuery(‘ul’).attr(‘id’, ‘nav’);
                                    2
  jQuery(‘#nav li’).addClass(‘item’);
  jQuery(‘#nav a’).each(function () {
    jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
  });
</script>
              3
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘ul’).attr(‘id’, ‘nav’);
  jQuery(‘#nav li’).addClass(‘item’);
  jQuery(‘#nav a’).each(function () {
    jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
  });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘ul’)
    .attr(‘id’, ‘nav’)
    .find(‘li’)
    .addClass(‘item’)
    .find(‘a’)
    .each(function () {
       jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
    });
</script>
</body>
</html>
Concept 5:
 understanding
implicit iteration
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘ul’)
    .attr(‘id’, ‘nav’)
    .find(‘li’)
    .addClass(‘item’)
    .find(‘a’)
    .each(function () {
       jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
    });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”><a href=”/home”>home</a></li>
    <li class=”item”><a href=”/about”>about</a></li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘ul’)
    .attr(‘id’, ‘nav’)
    .find(‘li’)
    .addClass(‘item’)
    .find(‘a’)
    .each(function () {
       jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());
    });
</script>
</body>
</html>
Review

• Knowing the jQuery parameter types
• Find something, do something
• Create something, do something
• Chaining & Operating
• Understanding Implicit Iteration
“What about the
bling function?”
jQuery == $
$ == jQuery
$ is an alias to jQuery
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
  jQuery(‘li’).addClass(‘item’);
</script>
</body>
</html>
<!DOCTYPE html>
 <html>
 <body>
   <ul id='nav'>
     <li class=”item”>home</li>
     <li class=”item”>about</li>
   </ul>
 <script src=”jquery.js”></script>
 <script>
jQuery(‘li’).addClass(‘item’);
 </script>
 </body>
 </html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
 $(‘li’).addClass(‘item’);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
  $(‘li’).addClass(‘item’);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
$(document).ready(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
$(document).ready(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
<script src=”jquery.js”></script>
<script>
$(document).ready(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src=”jquery.js”></script>
<script>
$(document).ready(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src=”jquery.js”></script>
<script>
$(document).ready(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src=”jquery.js”></script>
<script>
$(function () {
  $(‘li’).addClass(‘item’);
});
</script>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src=”jquery.js”></script>
<script>
jQuery(function ($) {
  $(‘li’).addClass(‘item’);
});
</script>
</head>
<body>
  <ul id='nav'>
    <li class=”item”>home</li>
    <li class=”item”>about</li>
  </ul>
</body>
</html>
jQuery API overview
•   Core

•   Selectors

•   Attributes

•   Traversing

•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           jQuery()

•   Selectors      each()
                   size()
•   Attributes     eq()
                   get()
•   Traversing     index()


•   Manipulation   length
                   selector
•   CSS            context


•   Events         data()
                   removeData()

•   Effects        queue()
                   dequeue()

•   Ajax           jQuery.fn.extend()

•   Utilities      jQuery.extend()
                   jQuery.noConflict()
•   Core           jQuery()

•   Selectors      each()
                   size()
•   Attributes     eq()
                   get()
•   Traversing     index()


•   Manipulation   length
                   selector
•   CSS            context


•   Events         data()
                   removeData()

•   Effects        queue()
                   dequeue()

•   Ajax           jQuery.fn.extend()

•   Utilities      jQuery.extend()
                   jQuery.noConflict()
•   Core           <!DOCTYPE html>

•   Selectors
                   <html>
                   <body>
•   Attributes
                   <p>Element Node</p>
•   Traversing

•
                   <script src="jquery.js">
    Manipulation   </script>

•   CSS            <script>
                   alert($('p').get(0).nodeName);
•   Events         </script>

•   Effects        </body>

•   Ajax           </html>


•   Utilities                    http://jsbin.com/ibito/edit
•   Core           <!DOCTYPE html>

•   Selectors
                   <html>
                   <body>
•   Attributes
                   <p>Element Node</p>
•   Traversing

•
                   <script src="jquery.js">
    Manipulation   </script>

•   CSS            <script>
                   alert($('p').get(0).nodeName);
•   Events         alert($('p')[0].nodeName);
                   </script>
•   Effects

•   Ajax           </body>
                   </html>
•   Utilities                    http://jsbin.com/idiyi/edit
•   Core

•   Selectors

•   Attributes

•   Traversing

•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors

•   Attributes

•   Traversing

•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes

•   Traversing

•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing

•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation

•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation
                   $(‘a[title][hash*=”foo”]’)
•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation
                   $(‘a[title][hash*=”foo”]’)
•   CSS
                   $(‘a:first[hash*=”foo”]’)
•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation
                   $(‘a[title][hash*=”foo”]’)
•   CSS
                   $(‘a:first[hash*=”foo”]’)
•   Events
                   $(‘.header, .footer’)
•   Effects

•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation
                   $(‘a[title][hash*=”foo”]’)
•   CSS
                   $(‘a:first[hash*=”foo”]’)
•   Events
                   $(‘.header, .footer’)
•   Effects
                   $(‘.header, .footer’, ‘#main’)
•   Ajax

•   Utilities
•   Core           $(‘#nav li.contact’)

•   Selectors      $(‘:visible’)

•   Attributes     $(‘:radio:enabled:checked’)

•   Traversing
                   $(‘a[title]’)
•   Manipulation
                   $(‘a[title][hash*=”foo”]’)
•   CSS
                   $(‘a:first[hash*=”foo”]’)
•   Events
                   $(‘.header, .footer’)
•   Effects
                   $(‘.header, .footer’, ‘#main’)
•   Ajax
                   http://codylindley.com/jqueryselectors
•   Utilities
•   Core          $(‘#nav li.contact’)

•   Selectors     $(‘:visible’)

•   Attributes    $(‘:radio:enabled:checked’)

•   Traversing
                   ry s  elec   tors
            jQue   $(‘a[title]’)
•   Manipulation
                        ilen  tly,
•                fail s
                   $(‘a[title][hash*=”foo”]’)
    CSS
                           SS d   oes!
•   Events just l  ike C
                   $(‘a:first[hash*=”foo”]’)

                  $(‘.header, .footer’)
•   Effects
                  $(‘.header, .footer’, ‘#main’)
•   Ajax
                  http://codylindley.com/jqueryselectors
•   Utilities
•   Core           attr()

•
                   removeAttr()
    Selectors
•   Attributes
                   addClass()
                   hasClass()

•   Traversing     toggleClass()
                   removeClass()
•   Manipulation
                   val()
•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           attr()

•
                   removeAttr()
    Selectors
•   Attributes
                   addClass()
                   hasClass()

•   Traversing     toggleClass()
                   removeClass()
•   Manipulation
                   val()
•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities
•   Core           <!DOCTYPE html><html><body>


•   Selectors      <input type="text" value="search">


•   Attributes     <script src="jquery.js"></script>
                   <script>

•   Traversing     $('input').focus(function(){

•   Manipulation
                     var v = $(this).val();
                     $(this).val(

•
                        v === this.defaultValue ? '' : v
    CSS              );

•
                   }).blur(function(){
    Events           var v = $(this).val();
                     $(this).val(
•   Effects
                     );
                        $.trim(v) ? v : this.defaultValue


•   Ajax           });


•   Utilities      </script></body></html>
                                    http://jsbin.com/akeqo3/edit
•   Core           add()            eq()

•
                   children()       filter()
    Selectors      closest()        is()

•   Attributes
                   contents()
                   find()
                                    map()
                                    not()

•   Traversing     next()
                   nextAll()
                                    slice()


•   Manipulation   offsetParent()
                   parent()
•   CSS            parents()
                   prev()
•   Events         prevAll()
                   siblings()
•   Effects
                   andSelf()
•   Ajax           end()

•   Utilities
• Core            add()            eq()

• Selectors
                  children()       filter()
                  closest()        is()

• Searches down
   Attributes
                  contents()
                  find()
                                   map()
                                   not()

• Traversing      next()
                  nextAll()
                                   slice()


• Manipulation    offsetParent()
                  parent()
• CSS             parents()
                  prev()
• Events          prevAll()
                  siblings()
• Effects         andSelf()
• Ajax            end()

• Utilities
•   Core           add()
                       Filters across
                                        eq()

•
                   children()           filter()
    Selectors      closest()            is()

•   Attributes
                   contents()
                   find()
                                        map()
                                        not()

•   Traversing     next()
                   nextAll()
                                        slice()


•   Manipulation   offsetParent()
                   parent()
•   CSS            parents()
                   prev()
•   Events         prevAll()
                   siblings()
•   Effects
                   andSelf()
•   Ajax           end()

•   Utilities
•   Core           add()            eq()

•
                   children()       filter()
    Selectors      closest()        is()

•   Attributes
                   contents()
                   find()
                                    map()
                                    not()

•   Traversing     next()
                   nextAll()
                                    slice()


•   Manipulation   offsetParent()
                   parent()
•   CSS            parents()
                   prev()
•   Events         prevAll()
                   siblings()
•   Effects
                   andSelf()
•   Ajax           end()

•   Utilities
•   Core           <!DOCTYPE html>

•
                   <html>
    Selectors      <body>

•   Attributes     <p>Make me bold!</p>

•   Traversing
                   <script src="jquery.js">
•   Manipulation   </script>
                   <script>
•   CSS
                   $('p')
•   Events           .contents()
                     .wrap('<strong />');
•   Effects
                   </script>
•   Ajax           </body>

•
                   </html>
    Utilities                   http://jsbin.com/owesu/edit
•   Core           html()          replaceWith()

•
                   text()          replaceAll()
    Selectors

•   Attributes
                   append()
                   appendTo()
                                   empty()
                                   remove()

•   Traversing     prepend()
                   prependTo()     clone()
•   Manipulation
                   after()
•   CSS            before()
                   insert()
•   Events         insertAfter()
                   insertBefore
•   Effects
                   wrap()
•   Ajax           wrapAll()

•
                   wrapInner()
    Utilities
•   Core           html()          replaceWith()

•
                   text()          replaceAll()
    Selectors

•   Attributes
                   append()
                   appendTo()
                                   empty()
                                   remove()

•   Traversing     prepend()
                   prependTo()     clone()
•   Manipulation
                   after()
•   CSS            before()
                   insert()
•   Events         insertAfter()
                   insertBefore
•   Effects
                   wrap()
•   Ajax           wrapAll()

•
                   wrapInner()
    Utilities
•   Core           <!DOCTYPE html>

•   Selectors
                   <html>
                   <body>
•   Attributes
                   <p>jQuery’s <em>easy!</em></p>
•   Traversing

•
                   <script src="jquery.js">
    Manipulation   </script>

•   CSS            <script>

•   Events         alert($(‘p’).text());

•   Effects        </script>

•   Ajax           </body>
                   </html>
•   Utilities                    http://jsbin.com/inulu/edit
•   Core           css()

•   Selectors      offset()

•   Attributes
                   offsetParent()
                   position()

•   Traversing     scrollTop()
                   scrollLeft()
•   Manipulation
                   height()
•   CSS            width()
                   innerHeight()
•   Events         innerWidth()
                   outerHeight()
•   Effects        outerWidth()

•   Ajax

•   Utilities
•   Core           css()

•   Selectors      offset()

•   Attributes
                   offsetParent()
                   position()

•   Traversing     scrollTop()
                   scrollLeft()
•   Manipulation
                   height()
•   CSS            width()
                   innerHeight()
•   Events         innerWidth()
                   outerHeight()
•   Effects        outerWidth()

•   Ajax

•   Utilities
•   Core           <!DOCTYPE html>
                   <html>

•   Selectors      <head>
                   <style>

•
                   div { background: #ccc; width: 100px;
    Attributes     margin: 0 20px; float: left; }
                   </style>

•   Traversing     </head>
                   <body>

•   Manipulation   <div></div>
                   <div></div>
•   CSS            <div></div>


•   Events
                   <script src=“jquery.js">
                   </script>


•
                   <script>
    Effects
                   $('div').height($(document).height());

•   Ajax           </script>

•
                   </body>
    Utilities      </html>           http://jsbin.com/erire3/edit
•   Core           ready()          blur()

•
                                    change()
    Selectors      bind()           click()

•   Attributes
                   one()
                   trigger()
                                    dbclick()
                                    focus()

•   Traversing     triggerHandler() keydown()
                   unbind()         keypress()
•   Manipulation
                   live()
                                    keyup()
                                    mousedown()
•   CSS            die()            mousenter()
                                    mouseleave()
•   Events         hover()
                   toggle()
                                    mouseout()
                                    mouseup()
•   Effects
                   load()
                                    resize()
                                    scroll()
•   Ajax           unload()         select()

•
                   error()          submit()
    Utilities
• Core                ready()          blur()

• Selectors
                                       change()
                      bind()           click()

• Acts on first, and
   Attributes
                      one()
                      trigger()
                                       dbclick()
                                       focus()

• Traversing
   doesn’t chain!     triggerHandler() keydown()
                      unbind()         keypress()
• Manipulation        live()
                                       keyup()
                                       mousedown()
• CSS                 die()            mousenter()
                                       mouseleave()
• Events              hover()
                      toggle()
                                       mouseout()
                                       mouseup()
• Effects             load()
                                       resize()
                                       scroll()
• Ajax                unload()         select()

• Utilities
                      error()          submit()
•   Core           ready()             blur()
                       IE fires on blur
•
                                       change()
    Selectors      bind()              click()

•   Attributes
                   one()
                   trigger()
                                       dbclick()
                                       focus()

•   Traversing     triggerHandler() keydown()
                   unbind()            keypress()
•   Manipulation
                   live()
                                       keyup()
                                       mousedown()
•   CSS            die()               mousenter()
                                       mouseleave()
•   Events         hover()
                   toggle()
                                       mouseout()
                                       mouseup()
•   Effects
                   load()
                                       resize()
                                       scroll()
•   Ajax           unload()            select()

•
                   error()             submit()
    Utilities
•   Core           ready()          blur()

•
                                    change()
    Selectors      bind()           click()

•   Attributes
                   one()
                   trigger()
                                    dbclick()
                                    focus()

•   Traversing     triggerHandler() keydown()
                   unbind()         keypress()
•   Manipulation
                   live()
                                    keyup()
                                    mousedown()
•   CSS            die()            mousenter()
                                    mouseleave()
•   Events         hover()
                   toggle()
                                    mouseout()
                                    mouseup()
•   Effects
                   load()
                                    resize()
                                    scroll()
•   Ajax           unload()         select()

•
                   error()          submit()
    Utilities
•   Core           <!DOCTYPE html>

•
                   <html>
    Selectors      <body>

•   Attributes     <p>1. click</p>

•   Traversing     <p>2. click</p>


•   Manipulation   <script src="jquery.js"></script>
                   <script>
•   CSS
                   $(‘p’).bind(‘click’, function(){
•   Events          $(this).after(‘<p>clicked</p>’);
                   });
•   Effects

•
                   </script>
    Ajax           </body>

•   Utilities      </html>
                                     http://jsbin.com/ogahu/edit
•   Core           <!DOCTYPE html>

•
                   <html>
    Selectors      <body>

•   Attributes     <p>1. click</p>

•   Traversing
                   <p>2. click</p>


•   Manipulation   <script src="jquery.js"></script>
                   <script>

•   CSS
                   $(‘p’).live(‘click’, function(){

•   Events          $(this).after(‘<p>’ +
                    ➥ $(this).text()+‘ clicked</p>’);
•   Effects        });


•   Ajax           </script>
                   </body>
•   Utilities      </html>           http://jsbin.com/ihalu/edit
•   Core           show()

•   Selectors
                   hide()
                   toggle()
•   Attributes
                   slideDown()
•   Traversing     slideUp()
                   slideToggle()
•   Manipulation

•   CSS            fadeIn()
                   fadeOut()
•   Events         fadeTo()

•   Effects        animate()

•
                   stop()
    Ajax

•   Utilities
•   Core           show()

•   Selectors
                   hide()
                   toggle()
•   Attributes
                   slideDown()
•   Traversing     slideUp()
                   slideToggle()
•   Manipulation

•   CSS            fadeIn()
                   fadeOut()
•   Events         fadeTo()

•   Effects        animate()

•
                   stop()
    Ajax

•   Utilities
•   Core           <!DOCTYPE html><html><head>
                   <style>
•   Selectors      div {background:#bca; width:100px;
                   border:1px solid green;}
•   Attributes     </style>
                   </head>
•   Traversing     <body>
                   <div id="block">Hello!</div>
•   Manipulation   <script src="jquery.js"></script>
                   <script>

•   CSS
                   $(‘#block’).animate({

•   Events         ! width: ‘70%’,
                   ! opacity: 0.4,

•   Effects        ! marginLeft: ‘0.6in’,
                   ! fontSize: ‘3em’,

•   Ajax
                   ! borderWidth: ‘10px’
                   }, 1500);
                                   http://jsbin.com/oroto/edit
•   Utilities      </script></body></html>
•   Core           $.ajax()        ajaxCompete()

•   Selectors
                   $.get()
                   $.post()
                                   ajaxError()
                                   ajaxSend()
•   Attributes     $.getJSON()
                   $.getScript()
                                   ajaxStart()
                                   ajaxStop()
•   Traversing     $.ajaxSetup()   ajaxSuccess()

•   Manipulation   load()

•   CSS
                   serialize()
•   Events         serializeArray()

•   Effects
•   Ajax

•   Utilities
•   Core           $.ajax()        ajaxCompete()

•   Selectors
                   $.get()
                   $.post()
                                   ajaxError()
                                   ajaxSend()
•   Attributes     $.getJSON()
                   $.getScript()
                                   ajaxStart()
                                   ajaxStop()
•   Traversing     $.ajaxSetup()   ajaxSuccess()

•   Manipulation   load()

•   CSS
                   serialize()
•   Events         serializeArray()

•   Effects
•   Ajax

•   Utilities
•   Core           <!DOCTYPE html><html><body>

•
                   <script src="jquery.js">
    Selectors      </script>

•   Attributes
                   <script>


•   Traversing     $.getJSON("http://twitter.com/
                   statuses/user_timeline.json?

•   Manipulation   screen_name=rem&callback=?",
                   function(data){
•   CSS              $.each(data,function(i,tweet){
                       $('<p/>').html
•   Events         (tweet.text).appendTo('body');
                       if ( i == 30 ) return false;
•   Effects          });

•
                   });
    Ajax           </script></body></html>

•   Utilities                      http://jsbin.com/acisi/edit
•   Core           $.support       $.isArray()

•   Selectors
                   $.boxModel
                   $.browser
                                   $.isFunction()


•   Attributes
                   $.each()
                                   $.trim()
                                   $.param()
•   Traversing     $.extend()
                   $.grep()
•   Manipulation   $.makeArray()

•   CSS            $.map()
                   $.inArray()
•   Events         $.merge()
                   $.unique()
•   Effects

•   Ajax

•   Utilities
•   Core           $.support       $.isArray()

•   Selectors
                   $.boxModel
                   $.browser
                                   $.isFunction()


•   Attributes
                   $.each()
                                   $.trim()
                                   $.param()
•   Traversing     $.extend()
                   $.grep()
•   Manipulation   $.makeArray()

•   CSS            $.map()
                   $.inArray()
•   Events         $.merge()
                   $.unique()
•   Effects

•   Ajax

•   Utilities
•   Core           $.each(data, function(i, tweet){

•
                     $('<p />')
    Selectors          .html(tweet.text)

•   Attributes
                       .appendTo('body');


•   Traversing       if ( i == 30 ) {
                       return false;

•   Manipulation     }
                   });
•   CSS

•   Events

•   Effects

•   Ajax

•   Utilities                      http://jsbin.com/acisi/edit
Plugins
What’s a plugin?
A plugin is nothing more than a custom
jQuery method created to extend the
functionality of the jQuery object


$(‘ul’).myPlugin()
Why create a plugin?


The “do something” isn’t available in jQuery
Why create a plugin?


Roll your own “do something” with a plugin!
A plugin in 6 steps
Step 1:
create a private
scope for $ alias
<!DOCTYPE html><html><body>
<script src=”jquery.js”></script>
<script>
(function ($) {

})(jQuery);
</script></body></html>
Step 2:
 attach plugin to fn
alias (aka prototype)
<!DOCTYPE html><html><body>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  $(this).text(
     $(this).text().replace(/hate/g, ‘love’)
  );
}; // end of plugin
})(jQuery);
</script></body></html>
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  $(this).text(
     $(this).text().replace(/hate/g, ‘love’)
  );
}; // end of plugin
})(jQuery);

$(‘p’).notHate();
</script></body></html>
Step 3:
add implicit iteration
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g, ‘love’)
    );
  });
}; // end of plugin
})(jQuery);

$(‘p’).notHate();
</script></body></html>
Step 4:
enable chaining
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g, ‘love’)
    );
  });
}; // end of plugin
})(jQuery);

$(‘p’).notHate().hide();
</script></body></html>
Step 5:
add default options
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g,
       ➥ $.fn.notHate.defaults.text)
    );
  });
}; // end of plugin
$.fn.notHate.defaults = {text:‘love’};
})(jQuery);

$(‘p’).notHate();
</script></body></html>
Step 6:
add custom options
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function () {
  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g,
       ➥ $.fn.notHate.defaults.text)
    );
  });
}; // end of plugin
$.fn.notHate.defaults = {text:‘love’};
})(jQuery);

$(‘p’).notHate({text: ‘love-love-love’});
</script></body></html>
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function (options) {
  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g,
       ➥ $.fn.notHate.defaults.text)
    );
  });
}; // end of plugin
$.fn.notHate.defaults = {text:‘love’};
})(jQuery);

$(‘p’).notHate({text: ‘love-love-love’});
</script></body></html>
<!DOCTYPE html><html><body>
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function (options) {
  var settings = $.extend({},
  ➥ $.fn.notHate.defaults, options);

  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g,
       ➥ $.fn.notHate.defaults.text)
    );
  });
}; // end of plugin
$.fn.notHate.defaults = {text:‘love’};
})(jQuery);

$(‘p’).notHate({text: ‘love-love-love’});
</script></body></html>
<!DOCTYPE html><html><body>          http://jsbin.com/ifuga/edit
<p>I hate jQuery!</p>
<p>I mean really hate jQuery!</p>
<script src=”jquery.js”></script>
<script>
(function ($) {
$.fn.notHate = function (options) {
  var settings = $.extend({},
  ➥ $.fn.notHate.defaults, options);

  return this.each(function () {
    $(this).text(
       $(this).text().replace(/hate/g,
       ➥ settings.text)
    );
  });
}; // end of plugin
$.fn.notHate.defaults = {text:‘love’};
})(jQuery);

$(‘p’).notHate({text: ‘love-love-love’});
</script></body></html>
Plugins are simple,
just follow those steps.
News
• Four conferences next year:
  London, Boston, San Francisco and online
• New plugin site
• jQuery Forum (moving from Google Groups)
• jQuery.org & Foundation (Software Freedom
  Law Centre)
• Infrastructure upgrade
Remy Sharp @rem

jQuery team member
Co-author of O'Reilly
jQuery Cookbook
(due November 20th)


jqueryfordesigners.com
remysharp.com


                         Special thanks to Cody Lindley
Remy Sharp @rem

jQuery team member
Co-author of O'Reilly
jQuery Cookbook
(due November 20th)


jqueryfordesigners.com
                                 ?
                         Questions
remysharp.com


                         Special thanks to Cody Lindley

More Related Content

What's hot

Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQueryRemy Sharp
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingDoug Neiner
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuerySudar Muthu
 
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...Thinqloud
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVCThomas Reynolds
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersJonathan Sharp
 

What's hot (20)

JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
jQuery
jQueryjQuery
jQuery
 
jQuery
jQueryjQuery
jQuery
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
jQuery
jQueryjQuery
jQuery
 
jQuery
jQueryjQuery
jQuery
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To 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 Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
Jquery-overview
Jquery-overviewJquery-overview
Jquery-overview
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVC
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
 

Similar to jQuery Overview: Core Concepts and API

Devdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for DevelopersDevdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for Developerscody lindley
 
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)Doris Chen
 
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02careersblog
 
J query presentation
J query presentationJ query presentation
J query presentationakanksha17
 
J query presentation
J query presentationJ query presentation
J query presentationsawarkar17
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationSean Burgess
 
The State of jQuery 2013
The State of jQuery 2013The State of jQuery 2013
The State of jQuery 2013Richard Worth
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile IntroGonzalo Parra
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile20111014 mu me_j_querymobile
20111014 mu me_j_querymobileErik Duval
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
CT presentatie JQuery 7.12.11
CT presentatie JQuery 7.12.11CT presentatie JQuery 7.12.11
CT presentatie JQuery 7.12.11virtualsciences41
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 
jQuery - Web Engineering
jQuery - Web Engineering jQuery - Web Engineering
jQuery - Web Engineering adeel990
 

Similar to jQuery Overview: Core Concepts and API (20)

Devdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for DevelopersDevdays Seattle jQuery Intro for Developers
Devdays Seattle jQuery Intro for Developers
 
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)
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
Jqueryforbeginnersjqueryconference2009 090914063709 Phpapp02
 
Jquery News Packages
Jquery News PackagesJquery News Packages
Jquery News Packages
 
J query presentation
J query presentationJ query presentation
J query presentation
 
J query presentation
J query presentationJ query presentation
J query presentation
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
The State of jQuery 2013
The State of jQuery 2013The State of jQuery 2013
The State of jQuery 2013
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
20111014 mu me_j_querymobile
20111014 mu me_j_querymobile20111014 mu me_j_querymobile
20111014 mu me_j_querymobile
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
CT presentatie JQuery 7.12.11
CT presentatie JQuery 7.12.11CT presentatie JQuery 7.12.11
CT presentatie JQuery 7.12.11
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
J query module1
J query module1J query module1
J query module1
 
JQuery
JQueryJQuery
JQuery
 
JQuery
JQueryJQuery
JQuery
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
jQuery - Web Engineering
jQuery - Web Engineering jQuery - Web Engineering
jQuery - Web Engineering
 

More from Remy Sharp

HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQueryRemy Sharp
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Forget the Web
Forget the WebForget the Web
Forget the WebRemy Sharp
 
Interaction Implementation
Interaction ImplementationInteraction Implementation
Interaction ImplementationRemy Sharp
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the newRemy Sharp
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?Remy Sharp
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsRemy Sharp
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for MobileRemy Sharp
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with WingsRemy Sharp
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the webRemy Sharp
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
 
codebits 2009 HTML5 JS APIs
codebits 2009 HTML5 JS APIscodebits 2009 HTML5 JS APIs
codebits 2009 HTML5 JS APIsRemy Sharp
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless AppsRemy Sharp
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & FriendsRemy Sharp
 
jQuery Loves Developers - SWDC2009
jQuery Loves Developers - SWDC2009jQuery Loves Developers - SWDC2009
jQuery Loves Developers - SWDC2009Remy Sharp
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryRemy Sharp
 

More from Remy Sharp (20)

HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Forget the Web
Forget the WebForget the Web
Forget the Web
 
Interaction Implementation
Interaction ImplementationInteraction Implementation
Interaction Implementation
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for Mobile
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
TwitterLib.js
TwitterLib.jsTwitterLib.js
TwitterLib.js
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
codebits 2009 HTML5 JS APIs
codebits 2009 HTML5 JS APIscodebits 2009 HTML5 JS APIs
codebits 2009 HTML5 JS APIs
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless Apps
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & Friends
 
HTML5 JS APIs
HTML5 JS APIsHTML5 JS APIs
HTML5 JS APIs
 
jQuery Loves Developers - SWDC2009
jQuery Loves Developers - SWDC2009jQuery Loves Developers - SWDC2009
jQuery Loves Developers - SWDC2009
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

jQuery Overview: Core Concepts and API

  • 1.
  • 2. Overview • Who, what and why of jQuery • 5 core jQuery concepts • Overview of jQuery API • Building a plugin in 6 steps • jQuery News
  • 5. Who's using jQuery reddit.com whitehouse.gov overstock.com espn.com microsoft.com time.com ibm.com amazon.com capitalone.com stackoverflow.com netflix.com wordpress.com boxee.tv bing.com dell.com bit.ly monster.com twitter.com twitpic.com tv.com w3.org http://trends.builtwith.com/javascript/jquery
  • 6. Who's using jQuery reddit.com whitehouse.gov overstock.com espn.com microsoft.com time.com ibm.com amazon.com capitalone.com stackoverflow.com netflix.com wordpress.com boxee.tv bing.com dell.com bit.ly monster.com twitter.com twitpic.com tv.com w3.org http://trends.builtwith.com/javascript/jquery
  • 7. What exactly is jQuery jQuery is a JavaScript library! • Dealing with the DOM changing, etc) (e.g. selecting, creating, traversing, • JavaScript Events • Animations • Ajax interactions
  • 9. It means no more of this var tables = document.getElementsByTagName('table'); for (var t = 0; t < tables.length; t++) { ! var rows = tables[t].getElementsByTagName('tr'); ! for (var i = 1; i < rows.length; i += 2) { if (!/(^|s)odd(s|$)/.test(rows[i].className)) { rows[i].className += ' odd'; } } }
  • 10. jQuery simpli es jQuery('table tr:nth-child(odd)').addClass('odd');
  • 11. jQuery simpli es jQuery function jQuery('table tr:nth-child(odd)').addClass('odd');
  • 12. jQuery simpli es jQuery function jQuery('table tr:nth-child(odd)').addClass('odd'); CSS expression
  • 13. jQuery simpli es jQuery function jQuery method jQuery('table tr:nth-child(odd)').addClass('odd'); CSS expression
  • 14. jQuery simpli es jQuery('table tr:nth-child(odd)').addClass('odd');
  • 15. It really is the Write less, do more JavaScript library!
  • 16. Why use jQuery • Helps us to simplify and speed up web development • Allows us to avoid common headaches associated with browser development • Provides a large pool of plugins • Large and active community • Tested on 50 browsers, 11 platforms • For both coder and designer (we don't discriminate)
  • 17. Why use jQuery • Helps us to simplify and speed up web development • Allows us to avoid common headaches associated with browser development • Provides a large pool of plugins • Large and active community • Tested on 50 browsers, 11 platforms • For both coder and designer (we don't discriminate)
  • 18. Help!
  • 19. APIs Blogs, tutorials, screencasts, docs.jquery.com plugins, development sprints api.jquery.com visualjquery.com Google Groups jquery-en Twitter jquery-dev @jquery Help! jquery-ui-en @jquerysites jquery-ui-dev @jqueryui jquery-a11y IRC channel irc.freenode.net/#jquery
  • 20. APIs Blogs, tutorials, screencasts, docs.jquery.com plugins, development sprints api.jquery.com visualjquery.com Google Groups jquery-en Twitter jquery-dev @jquery Help! jquery-ui-en @jquerysites jquery-ui-dev @jqueryui jquery-a11y IRC channel irc.freenode.net/#jquery
  • 21. Concept 1: knowing the jQuery parameter types
  • 22. • CSS selectors & custom CSS expressions • HTML • DOM elements • A function (shortcut for DOM ready)
  • 23. jQuery(‘div’) & jQuery(‘:first’) • CSS selectors & custom CSS expressions • HTML • DOM elements • A function (shortcut for DOM ready)
  • 24. jQuery(‘<li><a href=”#”>link</a></li>’) • CSS selectors jQuery(‘:first’) jQuery(‘div’) & & custom CSS expressions • HTML • DOM elements • A function (shortcut for DOM ready)
  • 25. jQuery(document) or jQuery(document.createElement(‘a’)) • CSS selectors jQuery(‘:first’) jQuery(‘div’) & & custom CSS expressions • HTML jQuery(‘<li><a href=”#”>link</a></li>’) • DOM elements • A function (shortcut for DOM ready)
  • 26. jQuery(function(){}) = jQuery(document).ready(function(){}) • CSS selectors jQuery(‘:first’) jQuery(‘div’) & & custom CSS expressions • HTML jQuery(‘<li><a href=”#”>link</a></li>’) • DOM elements jQuery(document) or jQuery(document.createElement(‘a’)) • A function (shortcut for DOM ready)
  • 27. • CSS selectors jQuery(‘:first’) jQuery(‘div’) & & custom CSS expressions • HTML jQuery(‘<li><a href=”#”>link</a></li>’) • DOM elements jQuery(document) or jQuery(document.createElement(‘a’)) • A function (shortcut for DOM ready) jQuery(function(){}) = jQuery(document).ready(function(){})
  • 29. <!DOCTYPE html> <html> <body> <ul> <li><a>home</a></li> <li><a>about</a></li> </ul> </body> </html>
  • 30. <!DOCTYPE html> <html> <body> <ul> <li><a>home</a></li> <li><a>about</a></li> </ul> <script src="jquery.js"></script> <script> jQuery('ul'); </script> </body> </html>
  • 31. <!DOCTYPE html> <html> <body> <ul id="nav"> <li><a>home</a></li> <li><a>about</a></li> </ul> <script src="jquery.js"></script> <script> jQuery('ul').attr('id', 'nav'); </script> </body> </html>
  • 32. <!DOCTYPE html> <html> <body> <ul id="nav"> <li><a>home</a></li> <li><a>about</a></li> </ul> <script src="jquery.js"></script> <script> jQuery('#nav a'); </script> </body> </html>
  • 33. <!DOCTYPE html> <html> <body> <ul id="nav"> <li><a href=”/home”>home</a></li> <li><a href=”/about”>about</a></li> </ul> <script src="jquery.js"></script> <script> jQuery('#nav a').each(function(){ jQuery(this).attr(‘href’, ➥ ‘/’ + jQuery(this).text()); }); </script> </body> </html>
  • 35. <!DOCTYPE html> <html> <body> <ul id='nav'> </ul> </body> </html>
  • 36. <!DOCTYPE html> <html> <body> <ul id='nav'> </ul> <script src=”jquery.js”></script> <script> jQuery(‘<li>home</li>’); jQuery(‘<li>about</li>’); </script> </body> </html>
  • 37. <!DOCTYPE html> <html> <body> <ul id='nav'> </ul> <script src=”jquery.js”></script> <script> jQuery(‘<li>home</li>’) ➥.wrapInner(‘<a/>’); jQuery(‘<li>about</li>’) ➥.wrapInner(‘<a/>’); </script> </body> </html>
  • 38. <!DOCTYPE html> <html> <body> <ul id='nav'> <li><a>home</a></li> <li><a>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘<li>home</li>’) ➥.wrapInner(‘<a/>’).appendTo(‘#nav’); jQuery(‘<li>about</li>’) ➥.wrapInner(‘<a/>’).appendTo(‘#nav’); </script> </body> </html>
  • 40. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘ul’).attr(‘id’, ‘nav’); jQuery(‘#nav li’).addClass(‘item’); jQuery(‘#nav a’).each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 41. <!DOCTYPE html> <html> 1 <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> 1 jQuery(‘ul’).attr(‘id’, ‘nav’); jQuery(‘#nav li’).addClass(‘item’); jQuery(‘#nav a’).each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 42. <!DOCTYPE html> <html> 1 <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> 2 <script src=”jquery.js”></script> <script> 1 jQuery(‘ul’).attr(‘id’, ‘nav’); 2 jQuery(‘#nav li’).addClass(‘item’); jQuery(‘#nav a’).each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 43. <!DOCTYPE html> <html> 1 <body> <ul id='nav'> 3 <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> 2 <script src=”jquery.js”></script> <script> 1 jQuery(‘ul’).attr(‘id’, ‘nav’); 2 jQuery(‘#nav li’).addClass(‘item’); jQuery(‘#nav a’).each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> 3 </body> </html>
  • 44. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘ul’).attr(‘id’, ‘nav’); jQuery(‘#nav li’).addClass(‘item’); jQuery(‘#nav a’).each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 45. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘ul’) .attr(‘id’, ‘nav’) .find(‘li’) .addClass(‘item’) .find(‘a’) .each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 47. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘ul’) .attr(‘id’, ‘nav’) .find(‘li’) .addClass(‘item’) .find(‘a’) .each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 48. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”><a href=”/home”>home</a></li> <li class=”item”><a href=”/about”>about</a></li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘ul’) .attr(‘id’, ‘nav’) .find(‘li’) .addClass(‘item’) .find(‘a’) .each(function () { jQuery(this).attr(‘href’, ‘/’+jQuery(this).text()); }); </script> </body> </html>
  • 49. Review • Knowing the jQuery parameter types • Find something, do something • Create something, do something • Chaining & Operating • Understanding Implicit Iteration
  • 50. “What about the bling function?”
  • 53. $ is an alias to jQuery
  • 54. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘li’).addClass(‘item’); </script> </body> </html>
  • 55. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> jQuery(‘li’).addClass(‘item’); </script> </body> </html>
  • 56. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> $(‘li’).addClass(‘item’); </script> </body> </html>
  • 57. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> $(‘li’).addClass(‘item’); </script> </body> </html>
  • 58. <!DOCTYPE html> <html> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> $(document).ready(function () { $(‘li’).addClass(‘item’); }); </script> </body> </html>
  • 59. <!DOCTYPE html> <html> <head> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> $(document).ready(function () { $(‘li’).addClass(‘item’); }); </script> </body> </html>
  • 60. <!DOCTYPE html> <html> <head> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> <script src=”jquery.js”></script> <script> $(document).ready(function () { $(‘li’).addClass(‘item’); }); </script> </body> </html>
  • 61. <!DOCTYPE html> <html> <head> <script src=”jquery.js”></script> <script> $(document).ready(function () { $(‘li’).addClass(‘item’); }); </script> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> </body> </html>
  • 62. <!DOCTYPE html> <html> <head> <script src=”jquery.js”></script> <script> $(document).ready(function () { $(‘li’).addClass(‘item’); }); </script> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> </body> </html>
  • 63. <!DOCTYPE html> <html> <head> <script src=”jquery.js”></script> <script> $(function () { $(‘li’).addClass(‘item’); }); </script> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> </body> </html>
  • 64. <!DOCTYPE html> <html> <head> <script src=”jquery.js”></script> <script> jQuery(function ($) { $(‘li’).addClass(‘item’); }); </script> </head> <body> <ul id='nav'> <li class=”item”>home</li> <li class=”item”>about</li> </ul> </body> </html>
  • 66. Core • Selectors • Attributes • Traversing • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 67. Core jQuery() • Selectors each() size() • Attributes eq() get() • Traversing index() • Manipulation length selector • CSS context • Events data() removeData() • Effects queue() dequeue() • Ajax jQuery.fn.extend() • Utilities jQuery.extend() jQuery.noConflict()
  • 68. Core jQuery() • Selectors each() size() • Attributes eq() get() • Traversing index() • Manipulation length selector • CSS context • Events data() removeData() • Effects queue() dequeue() • Ajax jQuery.fn.extend() • Utilities jQuery.extend() jQuery.noConflict()
  • 69. Core <!DOCTYPE html> • Selectors <html> <body> • Attributes <p>Element Node</p> • Traversing • <script src="jquery.js"> Manipulation </script> • CSS <script> alert($('p').get(0).nodeName); • Events </script> • Effects </body> • Ajax </html> • Utilities http://jsbin.com/ibito/edit
  • 70. Core <!DOCTYPE html> • Selectors <html> <body> • Attributes <p>Element Node</p> • Traversing • <script src="jquery.js"> Manipulation </script> • CSS <script> alert($('p').get(0).nodeName); • Events alert($('p')[0].nodeName); </script> • Effects • Ajax </body> </html> • Utilities http://jsbin.com/idiyi/edit
  • 71. Core • Selectors • Attributes • Traversing • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 72. Core $(‘#nav li.contact’) • Selectors • Attributes • Traversing • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 73. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes • Traversing • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 74. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 75. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation • CSS • Events • Effects • Ajax • Utilities
  • 76. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation $(‘a[title][hash*=”foo”]’) • CSS • Events • Effects • Ajax • Utilities
  • 77. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation $(‘a[title][hash*=”foo”]’) • CSS $(‘a:first[hash*=”foo”]’) • Events • Effects • Ajax • Utilities
  • 78. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation $(‘a[title][hash*=”foo”]’) • CSS $(‘a:first[hash*=”foo”]’) • Events $(‘.header, .footer’) • Effects • Ajax • Utilities
  • 79. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation $(‘a[title][hash*=”foo”]’) • CSS $(‘a:first[hash*=”foo”]’) • Events $(‘.header, .footer’) • Effects $(‘.header, .footer’, ‘#main’) • Ajax • Utilities
  • 80. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing $(‘a[title]’) • Manipulation $(‘a[title][hash*=”foo”]’) • CSS $(‘a:first[hash*=”foo”]’) • Events $(‘.header, .footer’) • Effects $(‘.header, .footer’, ‘#main’) • Ajax http://codylindley.com/jqueryselectors • Utilities
  • 81. Core $(‘#nav li.contact’) • Selectors $(‘:visible’) • Attributes $(‘:radio:enabled:checked’) • Traversing ry s elec tors jQue $(‘a[title]’) • Manipulation ilen tly, • fail s $(‘a[title][hash*=”foo”]’) CSS SS d oes! • Events just l ike C $(‘a:first[hash*=”foo”]’) $(‘.header, .footer’) • Effects $(‘.header, .footer’, ‘#main’) • Ajax http://codylindley.com/jqueryselectors • Utilities
  • 82. Core attr() • removeAttr() Selectors • Attributes addClass() hasClass() • Traversing toggleClass() removeClass() • Manipulation val() • CSS • Events • Effects • Ajax • Utilities
  • 83. Core attr() • removeAttr() Selectors • Attributes addClass() hasClass() • Traversing toggleClass() removeClass() • Manipulation val() • CSS • Events • Effects • Ajax • Utilities
  • 84. Core <!DOCTYPE html><html><body> • Selectors <input type="text" value="search"> • Attributes <script src="jquery.js"></script> <script> • Traversing $('input').focus(function(){ • Manipulation var v = $(this).val(); $(this).val( • v === this.defaultValue ? '' : v CSS ); • }).blur(function(){ Events var v = $(this).val(); $(this).val( • Effects ); $.trim(v) ? v : this.defaultValue • Ajax }); • Utilities </script></body></html> http://jsbin.com/akeqo3/edit
  • 85. Core add() eq() • children() filter() Selectors closest() is() • Attributes contents() find() map() not() • Traversing next() nextAll() slice() • Manipulation offsetParent() parent() • CSS parents() prev() • Events prevAll() siblings() • Effects andSelf() • Ajax end() • Utilities
  • 86. • Core add() eq() • Selectors children() filter() closest() is() • Searches down Attributes contents() find() map() not() • Traversing next() nextAll() slice() • Manipulation offsetParent() parent() • CSS parents() prev() • Events prevAll() siblings() • Effects andSelf() • Ajax end() • Utilities
  • 87. Core add() Filters across eq() • children() filter() Selectors closest() is() • Attributes contents() find() map() not() • Traversing next() nextAll() slice() • Manipulation offsetParent() parent() • CSS parents() prev() • Events prevAll() siblings() • Effects andSelf() • Ajax end() • Utilities
  • 88. Core add() eq() • children() filter() Selectors closest() is() • Attributes contents() find() map() not() • Traversing next() nextAll() slice() • Manipulation offsetParent() parent() • CSS parents() prev() • Events prevAll() siblings() • Effects andSelf() • Ajax end() • Utilities
  • 89. Core <!DOCTYPE html> • <html> Selectors <body> • Attributes <p>Make me bold!</p> • Traversing <script src="jquery.js"> • Manipulation </script> <script> • CSS $('p') • Events .contents() .wrap('<strong />'); • Effects </script> • Ajax </body> • </html> Utilities http://jsbin.com/owesu/edit
  • 90. Core html() replaceWith() • text() replaceAll() Selectors • Attributes append() appendTo() empty() remove() • Traversing prepend() prependTo() clone() • Manipulation after() • CSS before() insert() • Events insertAfter() insertBefore • Effects wrap() • Ajax wrapAll() • wrapInner() Utilities
  • 91. Core html() replaceWith() • text() replaceAll() Selectors • Attributes append() appendTo() empty() remove() • Traversing prepend() prependTo() clone() • Manipulation after() • CSS before() insert() • Events insertAfter() insertBefore • Effects wrap() • Ajax wrapAll() • wrapInner() Utilities
  • 92. Core <!DOCTYPE html> • Selectors <html> <body> • Attributes <p>jQuery’s <em>easy!</em></p> • Traversing • <script src="jquery.js"> Manipulation </script> • CSS <script> • Events alert($(‘p’).text()); • Effects </script> • Ajax </body> </html> • Utilities http://jsbin.com/inulu/edit
  • 93. Core css() • Selectors offset() • Attributes offsetParent() position() • Traversing scrollTop() scrollLeft() • Manipulation height() • CSS width() innerHeight() • Events innerWidth() outerHeight() • Effects outerWidth() • Ajax • Utilities
  • 94. Core css() • Selectors offset() • Attributes offsetParent() position() • Traversing scrollTop() scrollLeft() • Manipulation height() • CSS width() innerHeight() • Events innerWidth() outerHeight() • Effects outerWidth() • Ajax • Utilities
  • 95. Core <!DOCTYPE html> <html> • Selectors <head> <style> • div { background: #ccc; width: 100px; Attributes margin: 0 20px; float: left; } </style> • Traversing </head> <body> • Manipulation <div></div> <div></div> • CSS <div></div> • Events <script src=“jquery.js"> </script> • <script> Effects $('div').height($(document).height()); • Ajax </script> • </body> Utilities </html> http://jsbin.com/erire3/edit
  • 96. Core ready() blur() • change() Selectors bind() click() • Attributes one() trigger() dbclick() focus() • Traversing triggerHandler() keydown() unbind() keypress() • Manipulation live() keyup() mousedown() • CSS die() mousenter() mouseleave() • Events hover() toggle() mouseout() mouseup() • Effects load() resize() scroll() • Ajax unload() select() • error() submit() Utilities
  • 97. • Core ready() blur() • Selectors change() bind() click() • Acts on first, and Attributes one() trigger() dbclick() focus() • Traversing doesn’t chain! triggerHandler() keydown() unbind() keypress() • Manipulation live() keyup() mousedown() • CSS die() mousenter() mouseleave() • Events hover() toggle() mouseout() mouseup() • Effects load() resize() scroll() • Ajax unload() select() • Utilities error() submit()
  • 98. Core ready() blur() IE fires on blur • change() Selectors bind() click() • Attributes one() trigger() dbclick() focus() • Traversing triggerHandler() keydown() unbind() keypress() • Manipulation live() keyup() mousedown() • CSS die() mousenter() mouseleave() • Events hover() toggle() mouseout() mouseup() • Effects load() resize() scroll() • Ajax unload() select() • error() submit() Utilities
  • 99. Core ready() blur() • change() Selectors bind() click() • Attributes one() trigger() dbclick() focus() • Traversing triggerHandler() keydown() unbind() keypress() • Manipulation live() keyup() mousedown() • CSS die() mousenter() mouseleave() • Events hover() toggle() mouseout() mouseup() • Effects load() resize() scroll() • Ajax unload() select() • error() submit() Utilities
  • 100. Core <!DOCTYPE html> • <html> Selectors <body> • Attributes <p>1. click</p> • Traversing <p>2. click</p> • Manipulation <script src="jquery.js"></script> <script> • CSS $(‘p’).bind(‘click’, function(){ • Events $(this).after(‘<p>clicked</p>’); }); • Effects • </script> Ajax </body> • Utilities </html> http://jsbin.com/ogahu/edit
  • 101. Core <!DOCTYPE html> • <html> Selectors <body> • Attributes <p>1. click</p> • Traversing <p>2. click</p> • Manipulation <script src="jquery.js"></script> <script> • CSS $(‘p’).live(‘click’, function(){ • Events $(this).after(‘<p>’ + ➥ $(this).text()+‘ clicked</p>’); • Effects }); • Ajax </script> </body> • Utilities </html> http://jsbin.com/ihalu/edit
  • 102. Core show() • Selectors hide() toggle() • Attributes slideDown() • Traversing slideUp() slideToggle() • Manipulation • CSS fadeIn() fadeOut() • Events fadeTo() • Effects animate() • stop() Ajax • Utilities
  • 103. Core show() • Selectors hide() toggle() • Attributes slideDown() • Traversing slideUp() slideToggle() • Manipulation • CSS fadeIn() fadeOut() • Events fadeTo() • Effects animate() • stop() Ajax • Utilities
  • 104. Core <!DOCTYPE html><html><head> <style> • Selectors div {background:#bca; width:100px; border:1px solid green;} • Attributes </style> </head> • Traversing <body> <div id="block">Hello!</div> • Manipulation <script src="jquery.js"></script> <script> • CSS $(‘#block’).animate({ • Events ! width: ‘70%’, ! opacity: 0.4, • Effects ! marginLeft: ‘0.6in’, ! fontSize: ‘3em’, • Ajax ! borderWidth: ‘10px’ }, 1500); http://jsbin.com/oroto/edit • Utilities </script></body></html>
  • 105. Core $.ajax() ajaxCompete() • Selectors $.get() $.post() ajaxError() ajaxSend() • Attributes $.getJSON() $.getScript() ajaxStart() ajaxStop() • Traversing $.ajaxSetup() ajaxSuccess() • Manipulation load() • CSS serialize() • Events serializeArray() • Effects • Ajax • Utilities
  • 106. Core $.ajax() ajaxCompete() • Selectors $.get() $.post() ajaxError() ajaxSend() • Attributes $.getJSON() $.getScript() ajaxStart() ajaxStop() • Traversing $.ajaxSetup() ajaxSuccess() • Manipulation load() • CSS serialize() • Events serializeArray() • Effects • Ajax • Utilities
  • 107. Core <!DOCTYPE html><html><body> • <script src="jquery.js"> Selectors </script> • Attributes <script> • Traversing $.getJSON("http://twitter.com/ statuses/user_timeline.json? • Manipulation screen_name=rem&callback=?", function(data){ • CSS $.each(data,function(i,tweet){ $('<p/>').html • Events (tweet.text).appendTo('body'); if ( i == 30 ) return false; • Effects }); • }); Ajax </script></body></html> • Utilities http://jsbin.com/acisi/edit
  • 108. Core $.support $.isArray() • Selectors $.boxModel $.browser $.isFunction() • Attributes $.each() $.trim() $.param() • Traversing $.extend() $.grep() • Manipulation $.makeArray() • CSS $.map() $.inArray() • Events $.merge() $.unique() • Effects • Ajax • Utilities
  • 109. Core $.support $.isArray() • Selectors $.boxModel $.browser $.isFunction() • Attributes $.each() $.trim() $.param() • Traversing $.extend() $.grep() • Manipulation $.makeArray() • CSS $.map() $.inArray() • Events $.merge() $.unique() • Effects • Ajax • Utilities
  • 110. Core $.each(data, function(i, tweet){ • $('<p />') Selectors .html(tweet.text) • Attributes .appendTo('body'); • Traversing if ( i == 30 ) { return false; • Manipulation } }); • CSS • Events • Effects • Ajax • Utilities http://jsbin.com/acisi/edit
  • 112. What’s a plugin? A plugin is nothing more than a custom jQuery method created to extend the functionality of the jQuery object $(‘ul’).myPlugin()
  • 113. Why create a plugin? The “do something” isn’t available in jQuery
  • 114. Why create a plugin? Roll your own “do something” with a plugin!
  • 115. A plugin in 6 steps
  • 116. Step 1: create a private scope for $ alias
  • 118. Step 2: attach plugin to fn alias (aka prototype)
  • 119. <!DOCTYPE html><html><body> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }; // end of plugin })(jQuery); </script></body></html>
  • 120. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }; // end of plugin })(jQuery); $(‘p’).notHate(); </script></body></html>
  • 121. Step 3: add implicit iteration
  • 122. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { this.each(function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate(); </script></body></html>
  • 124. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate().hide(); </script></body></html>
  • 126. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate(); </script></body></html>
  • 127. Step 6: add custom options
  • 128. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>
  • 129. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function (options) { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>
  • 130. <!DOCTYPE html><html><body> <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function (options) { var settings = $.extend({}, ➥ $.fn.notHate.defaults, options); return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>
  • 131. <!DOCTYPE html><html><body> http://jsbin.com/ifuga/edit <p>I hate jQuery!</p> <p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function (options) { var settings = $.extend({}, ➥ $.fn.notHate.defaults, options); return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ settings.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>
  • 132.
  • 133. Plugins are simple, just follow those steps.
  • 134. News • Four conferences next year: London, Boston, San Francisco and online • New plugin site • jQuery Forum (moving from Google Groups) • jQuery.org & Foundation (Software Freedom Law Centre) • Infrastructure upgrade
  • 135. Remy Sharp @rem jQuery team member Co-author of O'Reilly jQuery Cookbook (due November 20th) jqueryfordesigners.com remysharp.com Special thanks to Cody Lindley
  • 136. Remy Sharp @rem jQuery team member Co-author of O'Reilly jQuery Cookbook (due November 20th) jqueryfordesigners.com ? Questions remysharp.com Special thanks to Cody Lindley