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

PDF
jQuery for beginners
PPTX
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
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
PDF
jQuery Features to Avoid
PPT
Intro to jQuery
PPT
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 Features to Avoid
Intro to 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

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

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

PPTX
J query1
PDF
22 j query1
PPTX
Jquery introduction
PPTX
Getting Started with jQuery
PPTX
Html dom & j query
PDF
Introduction to jQuery
PPT
J query lecture 1
PPTX
Web technologies-course 11.pptx
PPTX
FFW Gabrovo PMG - jQuery
ODP
Jquery- One slide completing all JQuery
PPTX
J111111111111111111111111111111111111111query.pptx
PPT
J query introduction
PPTX
Iniciando com jquery
PPTX
Jquery
PPTX
Getting Started with jQuery
PPTX
Web Development Introduction to jQuery
PDF
Learning jquery-in-30-minutes-1195942580702664-3
KEY
Bcblackpool jquery tips
PDF
J query 1.5-visual-cheat-sheet
PPTX
jQuery
J query1
22 j query1
Jquery introduction
Getting Started with jQuery
Html dom & j query
Introduction to jQuery
J query lecture 1
Web technologies-course 11.pptx
FFW Gabrovo PMG - jQuery
Jquery- One slide completing all JQuery
J111111111111111111111111111111111111111query.pptx
J query introduction
Iniciando com jquery
Jquery
Getting Started with jQuery
Web Development Introduction to jQuery
Learning jquery-in-30-minutes-1195942580702664-3
Bcblackpool jquery tips
J query 1.5-visual-cheat-sheet
jQuery

Recently uploaded (20)

PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
PPT
Overviiew on Intellectual property right
PDF
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
PPTX
Build automations faster and more reliably with UiPath ScreenPlay
PDF
Slides World Game (s) Great Redesign Eco Economic Epochs.pdf
PPTX
maintenance powerrpoint for adaprive and preventive
PDF
Internet of Things (IoT) – Definition, Types, and Uses
PDF
The AI Revolution in Customer Service - 2025
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
Child-friendly e-learning for artificial intelligence education in Indonesia:...
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
Overviiew on Intellectual property right
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
Build automations faster and more reliably with UiPath ScreenPlay
Slides World Game (s) Great Redesign Eco Economic Epochs.pdf
maintenance powerrpoint for adaprive and preventive
Internet of Things (IoT) – Definition, Types, and Uses
The AI Revolution in Customer Service - 2025
Addressing the challenges of harmonizing law and artificial intelligence tech...
NewMind AI Journal Monthly Chronicles - August 2025
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Report in SIP_Distance_Learning_Technology_Impact.pptx
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
EIS-Webinar-Regulated-Industries-2025-08.pdf
Presentation - Principles of Instructional Design.pptx
Domain-specific knowledge and context in large language models: challenges, c...
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...

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;