Introduction to jQuery

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

  • guest00060f guest00060f 5 months ago
    This also appears to be verbatim from the Manning Press book JQuery In Action. I am not sure 'verbatim' is fair, but it is very, very close. A great book, btw.
  • mirnazim Mir Nazim 2 years ago
    Manu

    The title is not Extending jQuery, but Introduction to jQuery

Post a comment
Embed Video
Edit your comment Cancel

16 Favorites & 2 Groups

Introduction to jQuery - Presentation Transcript

  1. jQuery
    • Javascript that doesn't suck!
    Presented By Mir Nazim www.mirnazim.com [email_address]
  2. WHAT and WHEN
    • John Resig - www.ejohn.org
    • Released at BarCamp NYC on Jan 2006
    • jQuery 1.0 out on Aug 2006
    • version 1.1.3 latest
      • ~ 800% faster for DOM processing
      • numerous other improvements
  3. WHY
    • Doesn’t mess with the language
          • (Prototype)
    • Doesn’t try to be Python
          • (Mochikit)
    • Only essentials: > 20 KB
          • (Scriptaculous, Dojo)
    • More than cosmetic effects
          • (Moo.fx)
    • Makes common tasks a breeze
  4. OTHER REASONS
    • Great Documentaions
    • Great community
    • Tons of plugins
    • Works everywhere RELIABLY
          • IE 6+, Firefox, Safari 2+, and Opera 9+
  5. What jQuery Deos
    • GENRAL PURPOSE
    • ABSTRACTION LAYER
    • FOR
    • COMMON
    • WEB SCRIPTING
    • TASKS
  6. What's Good in it
    • Access parts of a page
    • Modify the appearance of a page
    • Alter the content of a page
    • Respond to a user's interaction
    • Add animation to a page
    • Retrieve information (Ajax)
    • Simplify common tasks
  7. How jQuery does it
    • Leverage knowledge of CSS
    • Abstract away browser quirks
    • Always work with sets
    • Allow multiple actions in one line
    • Support extensions
  8. Getting Started
    • <head>
      • <script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;> </script>
      • <script type=&quot;text/javascript&quot;>
        • $(document).ready(function(){
          • // your stuff goes here
        • });
      • </script>
    • </head>
  9. The $() function
    • A factory for jQuery object
    • Provides a jQuery instance
    • All operations are done using $()
  10. Element Selection - CSS
    • $(document).ready(function(){
    • //select all ”p” elements
    • $(”p”);
    • //select an element with id=”soem-id”
    • $(”#some-id”);
    • //select all elements with class=”soem-class”
    • $(”.some-class”);
    • });
  11. More Element Selection
    • /* select 'li' elements that are children of 'ul' with id=”some-ul” */
    • $('ul#some-ul > li')
  12. Element Selection - XPath
    • //all links with a title attributes
    • $('a[@title]')
    • //all ”divs” containing on ”ol” element
    • $('div[ol]')
  13. Xpath + RegEx
    • //all links with ”href” starting with ”mailto:”
    • $('a[@href^=&quot;mailto:&quot;]')
    • //all links with ”href” ending with ”.pdf”
    • $('a[@href$=&quot;.pdf&quot;]')
    • //all links that contain ”mysite.com” anywhere in ”href”
    • $('a[@href*=&quot;mysite.com&quot;]')
  14. Custom Selectors
    • //selects 2 nd div from the set
    • $('div.someclass:eq(0)')
    • // same as above but CSS based
    • $('div.someclass:nth-child(1)')
  15. Select Even/Odd Rows of table
    • $('tr:odd') //all odd rows
    • $('tr:even') //all even rows
  16. DOM Traversal
    • Same Effect, Different way
    • $('tr').filter(':odd') //all odd rows
    • $('tr').filter(':even') //all even rows
  17. DOM Traversal
    • //select the parent element of ”th”
    • $('th').parent()
    • //select all even ”tr” but not that contain a ”th”
    • $('tr:not([th]):even')
    • //select all odd ”tr” but not that contain a ”th”
    • $('tr:not([th]):odd')
  18. More DOM
    • $('td:contains(&quot;Henry&quot;)').siblings()
    • $('td:contains(&quot;Henry&quot;)').parent().find('td:gt(0)')
    • $('td:contains(&quot;Henry&quot;)').parent().find('td')
      • .not(':contains(&quot;Henry&quot;)') )
    • $('td:contains(&quot;Henry&quot;)').parent().find('td:eq(1)')
  19. Method Chaining
    • //get every cell containing &quot;Henry&quot;
    • $('td:contains(&quot;Henry&quot;)')
    • //get its parent
    • .parent()
    • //find inside the parent the 2nd cell
    • .find('td:eq(1)')
    • //add the &quot;highlight&quot; class to that cell
    • .addClass(highlight')
    • //revert back to the parent of the cell containing &quot;Henry&quot;
    • .end()
    • //find inside the parent the 3rd cell
    • .find('td:eq(2)')
    • //add the &quot;highlight&quot; class to that cell
    • .addClass('highlight');
  20. Events
    • $('#some-element').bind('click',function() {
    • $('body').addClass('large');
    • //some more stuff
    • //even some more stuff
    • });
    • use event names without on part. E.G
    • onClick => click
      • onKeyPress => keypress
  21. Compound Events
    • // add and remove class on alternate clicks
    • $('#some-element'). toggle (function() {
      • $('#switcher.button').addClass('hidden');
    • }, function() {
      • $('#switcher.button').removeClass('hidden');
    • });
  22. One compound event
    • //works like ”:hover” pseudo class
    • $('#some-element').hover(function() {
      • $(this).addClass('hover');
    • }, function() {
      • $(this).removeClass('hover');
    • });
  23. Manipulating Attributes
    • //change the ”title” attribute of ”a” element where id=”some-id”
    • $('a#some-id').attr({'title': 'Some Text here'});
    • //more than one at a time
    • $('a#some-id').attr({
    • 'title':'Some Text here',
    • 'href':'www.example.com',
    • 'id':'some-other-id',
    • });
  24. Changing the tag content
    • //eq of element.innerHTML()
    • $('#some-div').html()
    • //eq of element.innerHTML = some-var
    • $('#some-div').html(some-var)
    • //eq of some-input.value
    • $('input').val()
    • //eq of some-input.value = some-var
    • $('input').val(some-var)
  25. AJAX
    • /* when a buttong with id=”some-button” is clicked load ”a.html” in div with id=”some-div” */
    • $('#some-button').click(function() {
    • $('#some-div').load('a.html');
    • });
  26. AJAX + JSON
    • $('#some-button').click(function() {
    • $.getJSON('b.json');
    • });
  27. Take action on data
    • $('#some-button').click(function() {
    • $.getJSON('b.json', function(data) {
    • // do some stuff with data you just go
    • });
  28. Execute a script
    • $('#some-button').click(function() {
      • $.getScript('c.js');
    • });
  29. Load other data formats
    • $('#some-button').click(function() {
    • $.get('my-format.data', function(data) {
        • //handle your data way you want
      • });
    • });
  30. A GET request
    • $.get('e.php',
    • {'term': $(this).text()},
    • function(data) {
    • $('#some-div').html(data);
    • }
    • );
  31. POST request
    • $.post('e.php',
    • {'term': $(this).text()},
    • function(data) {
    • $('#some-div').html(data);
    • }
    • );
  32. AJAX observers
    • $('#loading'). ajaxStart (function() {
    • $(this).show();
    • }). ajaxStop (function() {
    • $(this).hide();
    • });
  33. There is more
    • Loads of good quality plugins for
      • Extended AJAX functionality
      • Cool Effects
      • Extensions to core jQuery
      • much more
      • http://jquery.com/plugins
      • http://doc.jquery.com/Plugins
  34. Resources
    • http://doc.jquery.com
    • www.visualjquery.com
    • www.Google.com
      • 15 days of jQuery (blog)
      • Learning jQuery (blog)
  35.  
  36. Thanks A Millions
    • ?
    QEUSTIONS

manugoel2003manugoel2003, 2 years ago

custom

8764 views, 16 favs, 6 embeds more stats

Mir Nazim - Introduction to jQuery

More Info

© All Rights Reserved

Go to text version
  • Total Views 8764
    • 8730 on SlideShare
    • 34 from embeds
  • Comments 2
  • Favorites 16
  • Downloads 541
Most viewed embeds
  • 12 views on http://www.agglom.com
  • 10 views on http://cachina.wordpress.com
  • 8 views on http://www.webgox.com
  • 2 views on http://techno-sphere.blogspot.com
  • 1 views on http://egox.tumblr.com

more

All embeds
  • 12 views on http://www.agglom.com
  • 10 views on http://cachina.wordpress.com
  • 8 views on http://www.webgox.com
  • 2 views on http://techno-sphere.blogspot.com
  • 1 views on http://egox.tumblr.com
  • 1 views on http://192.168.10.25

less

Flagged as inappropriate Flag as inappropriate
Flag as innappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel

Categories

Groups / Events