SlideShare ist ein Scribd-Unternehmen logo
Sreenath H B
                                 +91 988 646 5897
                                 mail@sreenath.net
© Copyright SREENATH H B, 2011
                                 http://sreenath.net
jQuery Overview
        What is jQuery actually?
        How browsers see HTML
        JSON Overview
        Downloading jQuery
        Including jQuery in your pages
        Hello World




© Copyright SREENATH H B, 2011
                                         2
Selectors – The Heart of jQuery
        Element Selector
            $(“element”)
        ID Selector
            $(“#id”)
        Class Selector
            $(“.classname”)
        Ancestor Descendant
         $(“E F”)
        Parent Child
         $(“E > F”)
        Siblings – Adjacent & General
         Adjacent Sibling : $(“E + F”)
         General Siblings : $(“E ~ F”);
        Multiple Selectors
         $(“E, F, G”)

© Copyright SREENATH H B, 2011
                                          3
Selectors Contd..
        :first-child, :last:child, :only-child :nth-child(n)
         $(“li:first-child”);
         $(“tr:last-child”);
         $(“img:only-child”);
         $(“tr:nth-child(2n)”);
        Attribute Selectors
         Has Attribute: $(“img[alt]”);
         Begins With: $(“a[href^=mailto:]”);
         Ends With: $(“a[href$=.pdf]”);
         Contains: $(“a[href*=microsoft]”);
         Equals: $(“:checkbox[checked=true]”)
        :not(s), :empty, :eq(n), :contains(s)
        :even, :odd




© Copyright SREENATH H B, 2011
                                                               4
jQuery Tid-Bits
        The jQuery Object
        Looping with each();
        this
        Chaining
        Closures
        Accessing DOM Objects
                 Array Subscript – Unsafe
                 .get(n)
        Making peace with other libraries – noConflict()
        Caching for performance




© Copyright SREENATH H B, 2011
                                                           5
DOM Traversal
        .filter()
        .siblings()
        .parent(), .children(), .parents()
        .next(), .nextAll(), .prev(), .prevAll(), .andSelf()
        .find()

   Manipulating Styles
        .addClass()
        .removeClass()
        .css(“height”, “35px”)




© Copyright SREENATH H B, 2011
                                                               6
Events
 Unobtrusive Programming
 Capturing vs. Bubbling; StopPropagation, preventDefault
 The Universal Page Load
 Binding Events to Elements, Triggering Events via Code
 Shorthands
     Blur, focus, select
     Change
     Click, Dblclick
     Mousedown, mouseup, mouseover, mouseout, mousemove
     Keyup, keydown, keypress
     Select
 Event Handler Context
 Passing additional parameters to events
 Compound Events
     Toggle, Hover
 Live, Die & Delegate!             © Copyright SREENATH H B, 2011   7
Effects & Animations
        Hide, Show
        fadeIn, fadeOut
        Toggle
        slideUp, slideDown
        slideToggle
        .animate()




© Copyright SREENATH H B, 2011
                                 8
Working with Forms
        Form Selectors
                 :text
                 :checkbox
                 :radio
                 :image
                 :submit
                 :reset
                 :password
                 :file
                 :input
                 :button
                 :enabled
                 :disabled
                 :checked
                 :selected

© Copyright SREENATH H B, 2011
                                 9
DOM Manipulation
        .text()
        .html()
        .val()
        .append(), prepend()
        .remove()
        .empty()
        .attr(), .removeAttr()
        addClass(), removeClass()
        Creating DOM Nodes
        insertAfter, after, insertBefore, before
        prependTo, appendTo
        .wrap()



© Copyright SREENATH H B, 2011
                                                   10
AJAX
        .load(“a.html”)
        .getJSON(“b.json”);
        .get(“c.xml”);
        .post(“d.php”);
        .ajax({
                                 url:””,
                                  type:”GET”,
                                 dataType: “html”,
                                 success: function(data){
                                           },
                                 error: function(xhr){
                                           }
                    })



© Copyright SREENATH H B, 2011
                                                            11
Authoring Plugins
   (function($){
      $.fn.myPlugin = function(options){
            var defaults = { };
            options = $.extend(defaults, options);

                    return this.each(function(){
                             //My Code for selected elements
                    });
       }
   })(jQuery);

   //Calling
   $(“selector”).myPlugin({options})


© Copyright SREENATH H B, 2011
                                                               12
jQuery Best Practices – Tips & Tricks
        Select directly using an ID selector where possible
        Cache objects if using repeatedly
        Chain as long as possible
        Reduce Direct DOM Manipulation
        Be wary of selectors in loops or each()
        Leverage Event Delegation where possible
        Defer loading to window.load
        Don’t use jQuery where its not needed!
        Conditionally loading jQuery locally




© Copyright SREENATH H B, 2011
                                                              13
References
 Dive Into Accessibility
     http://diveintoaccessibility.org/
 Dive into HTML5
     http://diveintohtml5.org/
 Books
     Pro JavaScript Design Patterns by Dustin Diaz
     Object Oriented JavaScript by Stoyan Stefanov
     Advanced JavaScript 3rd Ed by Chuck Easttom
     Learning jQuery 1.3




                                                     14

Weitere ähnliche Inhalte

Ähnlich wie jQuery Training

jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue AdventureAllegient
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tipsanubavam-techkt
 
Web Front End - (HTML5, CSS3, JavaScript) ++
Web Front End - (HTML5, CSS3, JavaScript) ++Web Front End - (HTML5, CSS3, JavaScript) ++
Web Front End - (HTML5, CSS3, JavaScript) ++ubshreenath
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And TricksLester Lievens
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQueryPhDBrown
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQueryLaurence Svekis ✔
 
jQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda KatzjQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda KatzMarakana Inc.
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Libraryrsnarayanan
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperManoj Bhuva
 
A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETJames Johnson
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentationMevin Mohan
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETJames Johnson
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 

Ähnlich wie jQuery Training (20)

jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
 
Web Front End - (HTML5, CSS3, JavaScript) ++
Web Front End - (HTML5, CSS3, JavaScript) ++Web Front End - (HTML5, CSS3, JavaScript) ++
Web Front End - (HTML5, CSS3, JavaScript) ++
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And Tricks
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
 
Web Development Introduction to jQuery
Web Development Introduction to jQueryWeb Development Introduction to jQuery
Web Development Introduction to jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda KatzjQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda Katz
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
A to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java DeveloperA to Z about JQuery - Become Newbie to Expert Java Developer
A to Z about JQuery - Become Newbie to Expert Java Developer
 
A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NET
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Lec 5
Lec 5Lec 5
Lec 5
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
JQuery Overview
JQuery OverviewJQuery Overview
JQuery Overview
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 

Kürzlich hochgeladen

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfalexjohnson7307
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfChristopherTHyatt
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 

Kürzlich hochgeladen (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 

jQuery Training

  • 1. Sreenath H B +91 988 646 5897 mail@sreenath.net © Copyright SREENATH H B, 2011 http://sreenath.net
  • 2. jQuery Overview What is jQuery actually? How browsers see HTML JSON Overview Downloading jQuery Including jQuery in your pages Hello World © Copyright SREENATH H B, 2011 2
  • 3. Selectors – The Heart of jQuery Element Selector $(“element”) ID Selector $(“#id”) Class Selector $(“.classname”) Ancestor Descendant $(“E F”) Parent Child $(“E > F”) Siblings – Adjacent & General Adjacent Sibling : $(“E + F”) General Siblings : $(“E ~ F”); Multiple Selectors $(“E, F, G”) © Copyright SREENATH H B, 2011 3
  • 4. Selectors Contd.. :first-child, :last:child, :only-child :nth-child(n) $(“li:first-child”); $(“tr:last-child”); $(“img:only-child”); $(“tr:nth-child(2n)”); Attribute Selectors Has Attribute: $(“img[alt]”); Begins With: $(“a[href^=mailto:]”); Ends With: $(“a[href$=.pdf]”); Contains: $(“a[href*=microsoft]”); Equals: $(“:checkbox[checked=true]”) :not(s), :empty, :eq(n), :contains(s) :even, :odd © Copyright SREENATH H B, 2011 4
  • 5. jQuery Tid-Bits The jQuery Object Looping with each(); this Chaining Closures Accessing DOM Objects Array Subscript – Unsafe .get(n) Making peace with other libraries – noConflict() Caching for performance © Copyright SREENATH H B, 2011 5
  • 6. DOM Traversal .filter() .siblings() .parent(), .children(), .parents() .next(), .nextAll(), .prev(), .prevAll(), .andSelf() .find() Manipulating Styles .addClass() .removeClass() .css(“height”, “35px”) © Copyright SREENATH H B, 2011 6
  • 7. Events Unobtrusive Programming Capturing vs. Bubbling; StopPropagation, preventDefault The Universal Page Load Binding Events to Elements, Triggering Events via Code Shorthands Blur, focus, select Change Click, Dblclick Mousedown, mouseup, mouseover, mouseout, mousemove Keyup, keydown, keypress Select Event Handler Context Passing additional parameters to events Compound Events Toggle, Hover Live, Die & Delegate! © Copyright SREENATH H B, 2011 7
  • 8. Effects & Animations Hide, Show fadeIn, fadeOut Toggle slideUp, slideDown slideToggle .animate() © Copyright SREENATH H B, 2011 8
  • 9. Working with Forms Form Selectors :text :checkbox :radio :image :submit :reset :password :file :input :button :enabled :disabled :checked :selected © Copyright SREENATH H B, 2011 9
  • 10. DOM Manipulation .text() .html() .val() .append(), prepend() .remove() .empty() .attr(), .removeAttr() addClass(), removeClass() Creating DOM Nodes insertAfter, after, insertBefore, before prependTo, appendTo .wrap() © Copyright SREENATH H B, 2011 10
  • 11. AJAX .load(“a.html”) .getJSON(“b.json”); .get(“c.xml”); .post(“d.php”); .ajax({ url:””, type:”GET”, dataType: “html”, success: function(data){ }, error: function(xhr){ } }) © Copyright SREENATH H B, 2011 11
  • 12. Authoring Plugins (function($){ $.fn.myPlugin = function(options){ var defaults = { }; options = $.extend(defaults, options); return this.each(function(){ //My Code for selected elements }); } })(jQuery); //Calling $(“selector”).myPlugin({options}) © Copyright SREENATH H B, 2011 12
  • 13. jQuery Best Practices – Tips & Tricks Select directly using an ID selector where possible Cache objects if using repeatedly Chain as long as possible Reduce Direct DOM Manipulation Be wary of selectors in loops or each() Leverage Event Delegation where possible Defer loading to window.load Don’t use jQuery where its not needed! Conditionally loading jQuery locally © Copyright SREENATH H B, 2011 13
  • 14. References Dive Into Accessibility http://diveintoaccessibility.org/ Dive into HTML5 http://diveintohtml5.org/ Books Pro JavaScript Design Patterns by Dustin Diaz Object Oriented JavaScript by Stoyan Stefanov Advanced JavaScript 3rd Ed by Chuck Easttom Learning jQuery 1.3 14