jQuery
By
Shabab Shihan
Contact with me :
Skype : shabab.shihan1
Twitter : http://bit.ly/1HkfemT
Facebook : http://on.fb.me/1N3DhbN
Linkedin : http://bit.ly/1RGnZNF
Portfolio site : www.shababshihan.com
For hire me create your website :
http://bit.ly/1GTFk5b
 jQuery is a fast and concise JavaScript Library
that simplifies HTML document traversing, event
handling, animating, and Ajax interactions for
rapid web development. (jQuery.com)
What is jQuery?
 Write less, do more:
ā—¦ $("p.neat").addClass("ohmy").show("slow");
 Performance
 Plugins
 It’s standard
 … and fun!
Why learn jQuery?
Example: Show/Hide Button
 We cannot use the DOM before the page has
been constructed. jQuery gives us a more
compatibile way to do this.
ā—¦ The DOM way
ā—¦ The direct jQuery translation
ā—¦ The jQuery way
window.onload
window.onload = function() { // do stuff with the
$(document).ready(function() { // do stuff with the
$(function() { // do stuff with the DOM });
 Identification: how do I obtain a reference to the
node that I want.
 Traversal: how do I move around the DOM tree.
 Node Manipulation: how do I get or set aspects
of a DOM node.
 Tree Manipulation: how do I change the
structure of the page.
Aspects of the DOM and jQuery
The DOM tree
name description
getElementById returns array of descendents with
the given tag, such asĀ "div"
getElementsByTagName returns array of descendents with
the given tag, such asĀ "div"
getElementsByName returns array of descendents with
the givenĀ nameĀ attribute (mostly
useful for accessing form controls)
querySelectorĀ * returns the first element that would
be matched by the given CSS
selector string
querySelectorAllĀ * returns an array of all elements
that would be matched by the
given CSS selector string
Selecting groups of DOM objects
jQuery node identification
// id selector
var elem = $("#myid");
// group selector
var elems = $("#myid, p");
// context selector
var elems = $("#myid < div p");
// complex selector
var elems = $("#myid < h1.special:not(.classy)");
DOM method jQuery equivalent
getElementById("id") $("#id")
getElementsByTagName("tag") $("tag")
getElementsByName("somename") $("[name='somename']")
querySelector("selector") $("selector")
querySelectorAll("selector") $("selector")
jQuery / DOM comparison
 Use jQuery selectors to identify elements with these
properties in a hypothetical page:
ā—¦ AllĀ pĀ tags that have no children, but only if they don't have a
class ofĀ ignore
ā—¦ Any element with the text "REPLACE_ME" in it.
ā—¦ AllĀ divĀ tags with a child that has a class ofĀ special
ā—¦ All heading elements (h1,Ā h2,Ā h3,Ā h4,Ā h5,Ā h6)
ā—¦ Every other visibleĀ li.
 Use the DOM API to target the #square and periodically
change it's position in a random direction.
 Use jQuery selectors instead of the DOM API.
Exercise
 the jQuery function
refers to the global jQuery object or the $ function
depending on the context
 a jQuery object
the object returned by the jQuery function that often
represents a group of elements
 selected elements
the DOM elements that you have selected for, most likely
by some CSS selector passed to the jQuery function and
possibly later filtered further
jQuery terminology
 The $ function always (even for ID selectors) returns an
array-like object called a jQuery object.
 The jQuery object wraps the originally selected DOM
objects.
 You can access the actual DOM object by accessing the
elements of the jQuery object.
The jQuery object
// false
document.getElementById("id") == $("#myid");
document.querySelectorAll("p") == $("p");
// true
document.getElementById("id") == $("#myid")[0];
document.getElementById("id") == $("#myid").get(0);
document.querySelectorAll("p")[0] == $("p")[0];
 $ adds extra functionality to DOM elements
 passing an existing DOM object to $ will give it the
jQuery upgrade
Using $ as a wrapper
// convert regular DOM objects to a jQuery object
var elem = document.getElementById("myelem");
elem = $(elem);
var elems = document.querySelectorAll(".special");
elems = $(elems);
 You can use querySelectorAll() and querySelector() on
any DOM object.
 When you do this, it simply searches from that part of
the DOM tree downward.
 Programmatic equivalent of a CSS context selector
DOM context identification
var list = document.getElementsByTagName("ul")[0];
var specials = list.querySelectorAll('li.special');
 jQuery gives two identical ways to do contextual
element identification
findĀ / context parameter
var elem = $("#myid");
// These are identical
var specials = $("li.special", elem);
var specials = elem.find("li.special");
Types of DOM nodes
<p>
This is a paragraph of text with a
<a href="/path/page.html">link in it</a>.
</p>
name(s) description
firstChild, lastChild
start/end of this node's list
of children
childNodes
array of all this node's
children
nextSibling,
previousSibling
neighboring nodes with
the same parent
parentNode
the element that contains
this node
Traversing the DOM tree
•complete list of DOM node properties
•browser incompatiblity information (IE6 sucks)
DOM tree traversal example
<p id="foo">This is a paragraph of text with a
<a href="/path/to/another/page.html">link</a>.</p>
HTML
 Q: How many children does the div above have?
 A: 3
ā—¦ an element node representing the <p>
ā—¦ two text nodes representing "nt" (before/after the
paragraph)
 Q: How many children does the paragraph have?
The a tag?
Elements vs text nodes
<div>
<p>
This is a paragraph of text with a
<a href="page.html">link</a>.
</p>
</div> HTML
Contact with me :
Skype : shabab.shihan1
Twitter : http://bit.ly/1HkfemT
Facebook : http://on.fb.me/1N3DhbN
Linkedin : http://bit.ly/1RGnZNF
Portfolio site : www.shababshihan.com
For hire me create your website :
http://bit.ly/1GTFk5b

More Related Content

PPT
PDF
jQuery for beginners
PPTX
jQuery
PPTX
JavaScript and jQuery Basics
PPTX
jQuery Presentation
PPTX
jQuery Fundamentals
PDF
jQuery Loves Developers - Oredev 2009
PDF
Write Less Do More
jQuery for beginners
jQuery
JavaScript and jQuery Basics
jQuery Presentation
jQuery Fundamentals
jQuery Loves Developers - Oredev 2009
Write Less Do More

What's hot (20)

PDF
Introducing jQuery
PPTX
JQuery
PPTX
Unobtrusive javascript with jQuery
PPT
jQuery
PDF
jQuery Features to Avoid
PPT
Intro to jQuery
PPT
jQuery
PPT
JQuery introduction
PPTX
jQuery Best Practice
PDF
jQuery Introduction
PDF
Game jump: frontend introduction #1
KEY
Week 4 - jQuery + Ajax
PDF
Learn css3
PPTX
Introduction to jQuery
PPT
J Query Public
PDF
Devoxx 2014-webComponents
PDF
jQuery: Nuts, Bolts and Bling
PDF
jQuery Essentials
PPTX
Getting the Most Out of jQuery Widgets
PPTX
Jquery Basics
Introducing jQuery
JQuery
Unobtrusive javascript with jQuery
jQuery
jQuery Features to Avoid
Intro to jQuery
jQuery
JQuery introduction
jQuery Best Practice
jQuery Introduction
Game jump: frontend introduction #1
Week 4 - jQuery + Ajax
Learn css3
Introduction to jQuery
J Query Public
Devoxx 2014-webComponents
jQuery: Nuts, Bolts and Bling
jQuery Essentials
Getting the Most Out of jQuery Widgets
Jquery Basics
Ad

Viewers also liked (9)

PPTX
Varroosis filapi 14
PDF
Practitioner brochure 2016
PPTX
Evaluation 7
PDF
Apostila de banco de dados da ucg
PPTX
Interview questions and answers for salesforce developer
DOCX
Week4 team
PPTX
Punjabi language
PDF
Practitioner in PNL 2016
PDF
Practitioner PNL - Brochure 2017
Varroosis filapi 14
Practitioner brochure 2016
Evaluation 7
Apostila de banco de dados da ucg
Interview questions and answers for salesforce developer
Week4 team
Punjabi language
Practitioner in PNL 2016
Practitioner PNL - Brochure 2017
Ad

Similar to Don't Worry jQuery is very Easy:Learning Tips For jQuery (20)

PPTX
J query1
PPTX
Jquery introduction
PDF
22 j query1
PPT
JavaScript: Ajax & DOM Manipulation
PPTX
PPTX
jQuery
PDF
Advanced JQuery Mobile tutorial with Phonegap
PPTX
Jquery Complete Presentation along with Javascript Basics
PPTX
FFW Gabrovo PMG - jQuery
PPTX
jQuery Presentasion
PPTX
Jquery
PPTX
Jquery fundamentals
PPTX
How to increase Performance of Web Application using JQuery
PPTX
JQuery
PDF
jQuery
PPTX
jQuery Performance Tips and Tricks
PPTX
JQuery_and_Ajax.pptx
PPTX
Jquery optimization-tips
PDF
Introduction to jQuery
PDF
Learning jQuery made exciting in an interactive session by one of our team me...
J query1
Jquery introduction
22 j query1
JavaScript: Ajax & DOM Manipulation
jQuery
Advanced JQuery Mobile tutorial with Phonegap
Jquery Complete Presentation along with Javascript Basics
FFW Gabrovo PMG - jQuery
jQuery Presentasion
Jquery
Jquery fundamentals
How to increase Performance of Web Application using JQuery
JQuery
jQuery
jQuery Performance Tips and Tricks
JQuery_and_Ajax.pptx
Jquery optimization-tips
Introduction to jQuery
Learning jQuery made exciting in an interactive session by one of our team me...

Recently uploaded (20)

PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Internet of Everything -Basic concepts details
PDF
CloudStack 4.21: First Look Webinar slides
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PPTX
Training Program for knowledge in solar cell and solar industry
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPT
What is a Computer? Input Devices /output devices
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
4 layer Arch & Reference Arch of IoT.pdf
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PPTX
TEXTILE technology diploma scope and career opportunities
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPT
Geologic Time for studying geology for geologist
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Internet of Everything -Basic concepts details
CloudStack 4.21: First Look Webinar slides
UiPath Agentic Automation session 1: RPA to Agents
sbt 2.0: go big (Scala Days 2025 edition)
Enhancing plagiarism detection using data pre-processing and machine learning...
Training Program for knowledge in solar cell and solar industry
Final SEM Unit 1 for mit wpu at pune .pptx
Getting started with AI Agents and Multi-Agent Systems
NewMind AI Weekly Chronicles – August ’25 Week III
Custom Battery Pack Design Considerations for Performance and Safety
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Developing a website for English-speaking practice to English as a foreign la...
What is a Computer? Input Devices /output devices
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
4 layer Arch & Reference Arch of IoT.pdf
Basics of Cloud Computing - Cloud Ecosystem
TEXTILE technology diploma scope and career opportunities
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Geologic Time for studying geology for geologist

Don't Worry jQuery is very Easy:Learning Tips For jQuery

  • 2. Contact with me : Skype : shabab.shihan1 Twitter : http://bit.ly/1HkfemT Facebook : http://on.fb.me/1N3DhbN Linkedin : http://bit.ly/1RGnZNF Portfolio site : www.shababshihan.com For hire me create your website : http://bit.ly/1GTFk5b
  • 3.  jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. (jQuery.com) What is jQuery?
  • 4.  Write less, do more: ā—¦ $("p.neat").addClass("ohmy").show("slow");  Performance  Plugins  It’s standard  … and fun! Why learn jQuery?
  • 6.  We cannot use the DOM before the page has been constructed. jQuery gives us a more compatibile way to do this. ā—¦ The DOM way ā—¦ The direct jQuery translation ā—¦ The jQuery way window.onload window.onload = function() { // do stuff with the $(document).ready(function() { // do stuff with the $(function() { // do stuff with the DOM });
  • 7.  Identification:Ā how do I obtain a reference to the node that I want.  Traversal:Ā how do I move around the DOM tree.  Node Manipulation:Ā how do I get or set aspects of a DOM node.  Tree Manipulation:Ā how do I change the structure of the page. Aspects of the DOM and jQuery
  • 9. name description getElementById returns array of descendents with the given tag, such asĀ "div" getElementsByTagName returns array of descendents with the given tag, such asĀ "div" getElementsByName returns array of descendents with the givenĀ nameĀ attribute (mostly useful for accessing form controls) querySelectorĀ * returns the first element that would be matched by the given CSS selector string querySelectorAllĀ * returns an array of all elements that would be matched by the given CSS selector string Selecting groups of DOM objects
  • 10. jQuery node identification // id selector var elem = $("#myid"); // group selector var elems = $("#myid, p"); // context selector var elems = $("#myid < div p"); // complex selector var elems = $("#myid < h1.special:not(.classy)");
  • 11. DOM method jQuery equivalent getElementById("id") $("#id") getElementsByTagName("tag") $("tag") getElementsByName("somename") $("[name='somename']") querySelector("selector") $("selector") querySelectorAll("selector") $("selector") jQuery / DOM comparison
  • 12.  Use jQuery selectors to identify elements with these properties in a hypothetical page: ā—¦ AllĀ pĀ tags that have no children, but only if they don't have a class ofĀ ignore ā—¦ Any element with the text "REPLACE_ME" in it. ā—¦ AllĀ divĀ tags with a child that has a class ofĀ special ā—¦ All heading elements (h1,Ā h2,Ā h3,Ā h4,Ā h5,Ā h6) ā—¦ Every other visibleĀ li.  Use the DOM API to target theĀ #squareĀ and periodically change it's position in a random direction.  Use jQuery selectors instead of the DOM API. Exercise
  • 13.  the jQuery function refers to the global jQuery object or the $ function depending on the context  a jQuery object the object returned by the jQuery function that often represents a group of elements  selected elements the DOM elements that you have selected for, most likely by some CSS selector passed to the jQuery function and possibly later filtered further jQuery terminology
  • 14.  TheĀ $Ā function always (even for ID selectors) returns an array-like object called a jQuery object.  The jQuery object wraps the originally selected DOM objects.  You can access the actual DOM object by accessing the elements of the jQuery object. The jQuery object // false document.getElementById("id") == $("#myid"); document.querySelectorAll("p") == $("p"); // true document.getElementById("id") == $("#myid")[0]; document.getElementById("id") == $("#myid").get(0); document.querySelectorAll("p")[0] == $("p")[0];
  • 15.  $Ā adds extra functionality to DOM elements  passing an existing DOM object toĀ $Ā will give it the jQuery upgrade Using $ as a wrapper // convert regular DOM objects to a jQuery object var elem = document.getElementById("myelem"); elem = $(elem); var elems = document.querySelectorAll(".special"); elems = $(elems);
  • 16.  You can useĀ querySelectorAll()Ā andĀ querySelector()Ā on any DOM object.  When you do this, it simply searches from that part of the DOM tree downward.  Programmatic equivalent of a CSS context selector DOM context identification var list = document.getElementsByTagName("ul")[0]; var specials = list.querySelectorAll('li.special');
  • 17.  jQuery gives two identical ways to do contextual element identification findĀ / context parameter var elem = $("#myid"); // These are identical var specials = $("li.special", elem); var specials = elem.find("li.special");
  • 18. Types of DOM nodes <p> This is a paragraph of text with a <a href="/path/page.html">link in it</a>. </p>
  • 19. name(s) description firstChild, lastChild start/end of this node's list of children childNodes array of all this node's children nextSibling, previousSibling neighboring nodes with the same parent parentNode the element that contains this node Traversing the DOM tree •complete list of DOM node properties •browser incompatiblity information (IE6 sucks)
  • 20. DOM tree traversal example <p id="foo">This is a paragraph of text with a <a href="/path/to/another/page.html">link</a>.</p> HTML
  • 21.  Q: How many children does the div above have?  A: 3 ā—¦ an element node representing the <p> ā—¦ two text nodes representing "nt" (before/after the paragraph)  Q: How many children does the paragraph have? The a tag? Elements vs text nodes <div> <p> This is a paragraph of text with a <a href="page.html">link</a>. </p> </div> HTML
  • 22. Contact with me : Skype : shabab.shihan1 Twitter : http://bit.ly/1HkfemT Facebook : http://on.fb.me/1N3DhbN Linkedin : http://bit.ly/1RGnZNF Portfolio site : www.shababshihan.com For hire me create your website : http://bit.ly/1GTFk5b

Editor's Notes

  • #5: That little snippet loops through all &amp;lt;p&amp;gt; elements with the class &amp;quot;neat&amp;quot; and then adds the class &amp;quot;ohmy&amp;quot; to it, whilst slowly showing the paragraph in an animated effect. No browser checks, no loop code, no complex animation functions, just one line of code! &amp;lt;number&amp;gt;
  • #21: &amp;lt;number&amp;gt;