SlideShare a Scribd company logo
jQuery for Beginners
                                         write less, do more.



                                       October 18, 2012



    Sivasubramaniam Arunachalam
                      @sivaa_in
     http://www.meetup.com/Online-Technology-User-Group/events/86938772/
It’s me!

• Application Developer
• Technical Consultant
• Process Mentor
It’s about you!


Web(Site) Developer &
  Tasted JavaScript
Expectations
•   Introduction
•   JavaScript & jQuery
•   Basic features
•   Few static examples
•   Not a tutorial
•   Not a reference guide
My Bodhi Tree Moment
Simple JS Date Object (Case 01)
  var d = Date.parse("Wed Jun 25 12:05:12 +0000 2012");
  document.write(d);




  1277467512000     1277467512000       NaN
Simple JS Date Object (Case 02)
  var d = new Date("04-02-2012");
  document.write(d);



      Wed Apr 02 2012 00:00:00 GMT+0530 (India Standard Time)



      Wed Apr 2 00:00:00 UTC+0530 2012




        Invalid Date
jQuery - Introduction
jQuery - Introduction




jQuery = JavaScript
jQuery - Introduction




jQuery > JavaScript
jQuery - Introduction
jQuery History (Events)
 •   Barcamp NYC
 •   2006 (Version 1.0)
 •   Current Version 1.8.2
 •   Others
jQuery History (Founder)




          John Resig


     processing.js too
jQuery Download Formats
Who uses jQuery?



        55 %
http://docs.jquery.com/Sites_Using_jQuery
Why jQuery?
•   Cross Browser Support
•   Multi-Language Support
•   Works with Microsoft Tools
•   Awesome AJAX Support
•   Easy CSS Integration
•   Easy to learn and adopt
Benefits of jQuery
•    Write less, do more.
•    Deadlines
•    Keeps the code simple
•    Extensible & Lots of plugins
Does jQuery is faster than
       javascript?
Do NOT use jQuery
• About Page
• Info Pages
• Very less JS Actions
Lets Begin!
Download & include
Use it from Online
Let’s Test!
3 Examples
Just make it invisible!
Create a <h1> tag
Add “myClass” class to
  <div> child of <a>
Selectors
• Select DOM Elements
• Single (or) Array
• jQuery Objects
Basic Selectors
• Tag Name
• Tag ID
• Tag Class
Tag Name
document.getElementsByTagName(tagName)


                          Examples:
 Syntax: $(“tagName”)     •   $(“div”)
                          •   $(“p”)
                          •   $(“h1”)
                          •   $(“input”)
Tag ID
document.getElementById(“id”)


                        Examples:
Syntax: $(“#tagId”)     • $(“#firstName”)
                        • $(“#lastName”)
Tag Class
document.getElementsByClassName(“className”)


                         Examples:
Syntax: $(“.className”) • $(“.source”)
                         • $(“.comment”)
All Elements in a Page



       $(“*”)
Let’s Combine
Syntax:
$(“tagName.className”)
$(“tagName#tagId.className”)
Examples:
$(“h1.title”)
$(“h1#heading2.title”)
Advanced Selectors
• Combination of Selectors
• Hierarchical
• Order
Advanced Selectors
•   $(“selector1, selector2,…”)
•   $(“.class1, .class2,…”)
•   $(“ ancestor descendant”)
•   $(“ parent > child”)
•   $(“ previous + next”)
•   $(“ previous ~ siblings”)
Filters
• Always used with Selectors
• Filter/Restrict the Selector results
• CSS Style Conditions
Basic Filters
• Mostly used with Index
• Tag Specific Conditions
Index Filters
Syntax:                 Examples:
• $(“Selector:first”)   • $(“p:first”)
• $(“Selector:last”)    • $(“p:last”)
• $(“Selector:odd”)     • $(“div:odd”)
• $(“Selector:even”)    • $(“div:even”)

• $(“Selector:gt(i)”)   • $(“input:gt(i)”)
• $(“Selector:lt(i)”)   • $(“input:lt(i)”)
• $(“Selector:eq(i)”)   • $(“input:eq(i)”)
Condition Filters
Syntax:
• $(“Selector:visible”)
• $(“Selector:hidden”)
• $(“Selector:enabled”)
• $(“Selector:disabled”)
Condition Filters
Syntax:
• $(“Selector:checked”)
• $(“Selector:selected”)
Condition Filters
Syntax:
• $(“Selector:header”)
• $(“Selector:animated”)
• $(“Selector:not(Selector:not)”)
Relationship Filters
Syntax:
• $(“Selector:parent”)
• $(“Selector:first-child”)
• $(“Selector:last-child”)
Form Filters
Syntax:
• $(“Selector:input”)

• $(“Selector:text”)
• $(“Selector:password”)
Form Filters
Syntax:
• $(“Selector:radio”)
• $(“Selector:checkbox”)

• $(“Selector:submit”)
• $(“Selector:reset”)
Form Filters
Syntax:
• $(“Selector:image”)
• $(“Selector:file”)
• $(“Selector:button”)
You can combine filters!
 Syntax:
 • $(“Selector:filter1:filter2”)

 Example:
 • $(“form :text:enabled”)
Attributes
• [Selector + Filter] Results
  ď‚§ Filter & Retrieve Attribute(s)
  ď‚§ Set Attribute(s)
  ď‚§ Change Attribute(s)
Filter Attributes
Syntax:
• $(“[attribute]”)
• $(“[attribute1] [attribute2+….”)
• $(“[attribute=value]”)
• $(“[attribute!=value]”)
Filter Attributes
Syntax:
• $(“[attribute^=value]”)
• $(“[attribute$=value]”)
• $(“[attribute*=value]”)
Retrieve Attributes
Syntax:
• $(“Selector”).attr(name)


Example:
• $(“img”).attr(“src”)
Set Attributes – Type 01
 Syntax:
 • $(“Selector”).attr(key, value)

 Example:
 • $(“p”).attr(“class”, “source”);
Set Attributes – Type 02
 Syntax:
 • $(“Selector”).attr(key, function())

 Example:
 • $(“img”).attr(“alt”, calculateAlt());
Set Attributes – Type 03
 Syntax:
 • $(“Selector”).attr(properties)
 Example:
 • $(“img”).attr({
         “src” : “/path/pic.jpg,
         “title” : “My Title”
   });
Remove Attributes
Syntax:
• $(“Selector”).removeAttr(name)


Example:
• $(“div”). removeAttr(“class”)
Class Specific Attributes
Syntax:
• $(“Selector”).hasClass(className)
• $(“Selector”).removeClass(className)
• $(“Selector”).toggleClass(className)
HTML Specific Attributes
Syntax:
• $(“Selector”).html()
• $(“Selector”).html(“html code”)
Text Specific Attributes
Syntax:
• $(“Selector”).text()
• $(“Selector”).text(“text content”)
Value Specific Attributes
Syntax:
• $(“Selector”).val()
• $(“Selector”).val(“value”)
Traversing
•   length (or) size()
•   get()
•   get(index)
•   find()
•   each()
Traversing – length/size
 Syntax:
 • $(“Selector”).length)
 • $(“Selector”).size())
 Examples:
 • $(“h1”).length)
 • $(“div”).size())
Traversing – get
Syntax:
• $(“Selector”).get())
• $(“Selector”).get(index))
Examples:
• var h1_list = $(“h1”).get())
• var h1      = $(“h1”).get(2))
Traversing – find
Syntax:
• $(“Selector”).find(“Selector”))


Examples:
• $(“select”).find(“option*value*=“js”+”))
Traversing – each
Syntax:
$(“Selector”).each(function(){
        // $(this).xxxxx()
        }));

Example:
var border = 1;
$(“div”).each( function() {
        $(this).css(“border”, border+”px solid blue”);
        border++;
});
Basic Events
•   bind()
•   unbind()
•   ready()
•   toggle()
•   hover()
•   trigger()
Basic Events - bind

Syntax:
• $(“Selector”).bind(event, data, handler))
• $(“Selector”).unbind(event, handler))
Basic Events - bind
Example:
$(function() {
        $(“#myButton”).bind(“onclick”, validate)
});

function validate() {
        if($(“#myText”).val().length == 0)
                alert(“Error Text”);
        else
                submit();
}
Basic Animations
•   show()
•   hide()
•   fadeIn()
•   fadeOut()
•   slideDown()
•   slideUp()
Basic Animations – show/hide
Syntax:
• $(“Selector”).show(speed)
• $(“Selector”).hide(speed)
Speed:
• slow
• normal
• fast
Basic Animations – show/hide

Example:
    $("#showButton"). click(function () {
         $(“#mydiv").show(slow);
    });
Plug-ins
• jQuery Themes
• jQuery UI Libraries
  • Interactions
  • Widgets
  • Effects
jQuery Themes


http://themeroller.com
Interactions UI Libraries
•    Draggable
•    Droppable
•    Resizable
•    Selectable
•    Sortable
Widgets UI Libraries
•   Tabs
•   Date Picker
•   Progress bar
•   Slider
•   Dialog
•   Accordion
Effects UI Libraries
• show/hide/toggle
• add/remove/toggle class
• Color related Animations
AJAX
•   Awesome APIs
•   GET/POST
•   Event handlers
•   JSON Support
jQuery for beginners
Other JS Frameworks
•   AccDC              • MooTools
•   AJS                • Prototype
•   Ample SDK          • script.aculo.us
•   CupQ               • Pyjamas
•   DHTMLX             • qooxdoo
•   Dojo               • Rialto Toolkit
•   Echo3              • Rico
•   Enyo               • SmartClient & SmartGWT
•   Ext JS             • SweetDEV RIA
•   Google Web Toolkit • Wakanda
•   midori             • YUI
•   MochiKit           • ZK
Demo
Thank You!
  siva@sivaa.in
References
•   http://naturalpatriot.org/2011/02/11/the-buddhas-last-instruction/
•   http://ie.microsoft.com/testdrive/Graphics/IEBeatz/assets/ie-logo-small.png
•   http://cdn-static.zdnet.com/i/story/60/80/010270/firefox_.jpg
•   http://profile.ak.fbcdn.net/hprofile-ak-snc6/195785_321662419491_6364709_n.jpg
•   http://www.godaddymobile.com/entertainment/commercials.aspx
•   http://www.funnycommercialsworld.com/wp-content/uploads/2012/07/sharleen.jpg
•   http://en.wikipedia.org/wiki/JQuery
•   http://sunpig.com/martin/archives/2009/11/22/fronteers-conference-2009.html
•   http://jquery.com/
•   http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks

More Related Content

What's hot (20)

ODP
Introduction to jQuery
manugoel2003
 
PPTX
jQuery
Vishwa Mohan
 
PDF
Introduction to jQuery
Zeeshan Khan
 
PPTX
jQuery Fundamentals
Gil Fink
 
PPTX
Unobtrusive javascript with jQuery
Angel Ruiz
 
PPT
Jquery
Girish Srivastava
 
PDF
D3.js and SVG
Karol Depka Pradzinski
 
PDF
Learning jQuery made exciting in an interactive session by one of our team me...
Thinqloud
 
PDF
jQuery Features to Avoid
dmethvin
 
PDF
Learning jQuery in 30 minutes
Simon Willison
 
PPTX
jQuery from the very beginning
Anis Ahmad
 
PPT
A Short Introduction To jQuery
Sudar Muthu
 
PPTX
jQuery
Jay Poojara
 
PPTX
SharePoint and jQuery Essentials
Mark Rackley
 
PPTX
Jquery-overview
Isfand yar Khan
 
PDF
jQuery Introduction
Arwid Bancewicz
 
PDF
Prototype & jQuery
Remy Sharp
 
PDF
Stack Overflow Austin - jQuery for Developers
Jonathan Sharp
 
PDF
jQuery in 15 minutes
Simon Willison
 
PPTX
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
Introduction to jQuery
manugoel2003
 
jQuery
Vishwa Mohan
 
Introduction to jQuery
Zeeshan Khan
 
jQuery Fundamentals
Gil Fink
 
Unobtrusive javascript with jQuery
Angel Ruiz
 
D3.js and SVG
Karol Depka Pradzinski
 
Learning jQuery made exciting in an interactive session by one of our team me...
Thinqloud
 
jQuery Features to Avoid
dmethvin
 
Learning jQuery in 30 minutes
Simon Willison
 
jQuery from the very beginning
Anis Ahmad
 
A Short Introduction To jQuery
Sudar Muthu
 
jQuery
Jay Poojara
 
SharePoint and jQuery Essentials
Mark Rackley
 
Jquery-overview
Isfand yar Khan
 
jQuery Introduction
Arwid Bancewicz
 
Prototype & jQuery
Remy Sharp
 
Stack Overflow Austin - jQuery for Developers
Jonathan Sharp
 
jQuery in 15 minutes
Simon Willison
 
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 

Viewers also liked (20)

PPT
Getting started with angular js
Maurice De Beijer [MVP]
 
PPTX
jQuery PPT
Dominic Arrojado
 
PDF
jQuery for beginners
Arulmurugan Rajaraman
 
PDF
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
PDF
The Art of AngularJS in 2015
Matt Raible
 
PDF
000 introduction
sivorka
 
PDF
001 hosting
sivorka
 
PPTX
01 introduction to entity framework
Maxim Shaptala
 
PDF
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
PPTX
JSON: The Basics
Jeff Fox
 
PPTX
Jquery ppt
044249
 
KEY
Inside jQuery (2011)
Kenneth Auchenberg
 
PDF
C++ L02-Conversion+enum+Operators
Mohammad Shaker
 
PPTX
Java script
Abhishek Kesharwani
 
PPT
JSON - Quick Overview
Signure Technologies
 
PDF
Simplify AJAX using jQuery
Siva Arunachalam
 
PPT
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
S P Jain Institute of Management & Research (SPJIMR)
 
DOCX
Hari Resume
Hari Krishna
 
PPT
Inner core of Ajax
Muhammad Junaid Ansari
 
Getting started with angular js
Maurice De Beijer [MVP]
 
jQuery PPT
Dominic Arrojado
 
jQuery for beginners
Arulmurugan Rajaraman
 
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
The Art of AngularJS in 2015
Matt Raible
 
000 introduction
sivorka
 
001 hosting
sivorka
 
01 introduction to entity framework
Maxim Shaptala
 
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
JSON: The Basics
Jeff Fox
 
Jquery ppt
044249
 
Inside jQuery (2011)
Kenneth Auchenberg
 
C++ L02-Conversion+enum+Operators
Mohammad Shaker
 
Java script
Abhishek Kesharwani
 
JSON - Quick Overview
Signure Technologies
 
Simplify AJAX using jQuery
Siva Arunachalam
 
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
S P Jain Institute of Management & Research (SPJIMR)
 
Hari Resume
Hari Krishna
 
Inner core of Ajax
Muhammad Junaid Ansari
 
Ad

Similar to jQuery for beginners (20)

PPTX
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
David Giard
 
PPTX
Jquery
Zoya Shaikh
 
PPTX
Jquery fundamentals
Salvatore Fazio
 
PDF
Introduction to jQuery (Ajax Exp 2006)
jeresig
 
PDF
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
PPTX
J111111111111111111111111111111111111111query.pptx
dkmishra2407
 
PDF
Introduction to jQuery (Ajax Exp 2007)
jeresig
 
PDF
jQuery Rescue Adventure
Allegient
 
PPT
J query
Manav Prasad
 
PPTX
JQuery
DevTalk
 
PPTX
SEF2013 - A jQuery Primer for SharePoint
Marc D Anderson
 
PPTX
SharePoint Cincy 2012 - jQuery essentials
Mark Rackley
 
PDF
bcgr3-jquery
tutorialsruby
 
PDF
bcgr3-jquery
tutorialsruby
 
PDF
fuser interface-development-using-jquery
Kostas Mavridis
 
PPT
jQuery Learning
Uzair Ali
 
PPTX
SPTechCon DevDays - SharePoint & jQuery
Mark Rackley
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
David Giard
 
Jquery
Zoya Shaikh
 
Jquery fundamentals
Salvatore Fazio
 
Introduction to jQuery (Ajax Exp 2006)
jeresig
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
J111111111111111111111111111111111111111query.pptx
dkmishra2407
 
Introduction to jQuery (Ajax Exp 2007)
jeresig
 
jQuery Rescue Adventure
Allegient
 
J query
Manav Prasad
 
JQuery
DevTalk
 
SEF2013 - A jQuery Primer for SharePoint
Marc D Anderson
 
SharePoint Cincy 2012 - jQuery essentials
Mark Rackley
 
bcgr3-jquery
tutorialsruby
 
bcgr3-jquery
tutorialsruby
 
fuser interface-development-using-jquery
Kostas Mavridis
 
jQuery Learning
Uzair Ali
 
SPTechCon DevDays - SharePoint & jQuery
Mark Rackley
 
Ad

More from Siva Arunachalam (17)

PDF
Introduction to EDI(Electronic Data Interchange)
Siva Arunachalam
 
PDF
Introduction to logging in django
Siva Arunachalam
 
PDF
Introduction to Test Driven Development
Siva Arunachalam
 
PDF
Setup a New Virtualenv for Django in Windows
Siva Arunachalam
 
PDF
What's New in Django 1.6
Siva Arunachalam
 
PDF
Introduction to Browser Internals
Siva Arunachalam
 
PDF
Web sockets in java EE 7 - JavaOne 2013
Siva Arunachalam
 
PDF
Python for High School Programmers
Siva Arunachalam
 
PDF
Introduction to Cloud Computing
Siva Arunachalam
 
PDF
Web Sockets in Java EE 7
Siva Arunachalam
 
PDF
Introduction to Browser DOM
Siva Arunachalam
 
PDF
Installing MySQL for Python
Siva Arunachalam
 
PDF
Using Eclipse and Installing PyDev
Siva Arunachalam
 
PPT
Installing Python 2.7 in Windows
Siva Arunachalam
 
PDF
Setup a New Virtualenv for Django in Windows
Siva Arunachalam
 
PPT
Introduction to Google APIs
Siva Arunachalam
 
PDF
Introduction to Django
Siva Arunachalam
 
Introduction to EDI(Electronic Data Interchange)
Siva Arunachalam
 
Introduction to logging in django
Siva Arunachalam
 
Introduction to Test Driven Development
Siva Arunachalam
 
Setup a New Virtualenv for Django in Windows
Siva Arunachalam
 
What's New in Django 1.6
Siva Arunachalam
 
Introduction to Browser Internals
Siva Arunachalam
 
Web sockets in java EE 7 - JavaOne 2013
Siva Arunachalam
 
Python for High School Programmers
Siva Arunachalam
 
Introduction to Cloud Computing
Siva Arunachalam
 
Web Sockets in Java EE 7
Siva Arunachalam
 
Introduction to Browser DOM
Siva Arunachalam
 
Installing MySQL for Python
Siva Arunachalam
 
Using Eclipse and Installing PyDev
Siva Arunachalam
 
Installing Python 2.7 in Windows
Siva Arunachalam
 
Setup a New Virtualenv for Django in Windows
Siva Arunachalam
 
Introduction to Google APIs
Siva Arunachalam
 
Introduction to Django
Siva Arunachalam
 

Recently uploaded (20)

PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 

jQuery for beginners