SlideShare a Scribd company logo
Gil Fink
Senior Architect
SELA
jQuery
Fundamentals
www.devconnections.com
JQUERY FUNDAMENTALS
AGENDA
 Introduction to jQuery
 Selectors
 DOM Interactions
 Ajax Support
 Plugins
www.devconnections.com
JQUERY FUNDAMENTALS
WHAT IS JQUERY?
 Open-Source and lightweight JavaScript
library
 Cross-browser support
 DOM interaction
 Ajax
 Provides useful alternatives for common
programming tasks (CSS, HTML)
 Rich plugins eco-system
3
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY USAGE STATISTICS
4
http://trends.builtwith.com/javascript/jQuery
Websites using jQuery
www.devconnections.com
JQUERY FUNDAMENTALS
GETTING STARTED
 Download the latest version from
http://www.jquery.com
 Reference the jQuery script
 jQuery can be found on major CDNs
(Google, Microsoft)
5
<script type=„text/javascript‟ src=„jquery.min.js‟></script>
<script type=„text/javascript‟
src=„http://ajax.googleapis.com/ajax/libs/jquery/[version –
number]/jquery.min.js‟></script>
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
Setting up the environment
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY SYNTAX
7
$.func(…);
or
$(selector).func1(…).func2(…).funcN(…);
jQuery Object, can be used instead of jQuery
Selector syntax, many different selectors allowed
Chainable, most functions return a jQuery object
Function parameters
$
selector
func
(…)
www.devconnections.com
JQUERY FUNDAMENTALS
THE MAGIC $() FUNCTION
 Create HTML elements on the fly
 Manipulate existing DOM elements
 Selects document elements
 The full name of $() function is jQuery()
 may be used in case of conflict with other
frameworks
8
var el = $(“<div/>”)
$(window).width()
$(“div”).hide();
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY‟S PROGRAMMING PHILOSOPHY
GET >> ACT
9
$(“div”).hide()
$(“<span/>”).appendTo(“body”)
$(“:button”).click()
www.devconnections.com
JQUERY FUNDAMENTALS
FLUENT API
 Almost every function returns the jQuery
object
 Enables the chaining of function calls
10
$(“div”).show()
.addClass(“main”)
.html(“Hello jQuery”);
www.devconnections.com
JQUERY FUNDAMENTALS
THE READY FUNCTION
 Use $(document).ready() to detect
when a page is loaded and ready to use
 Called once the DOM hierarchy is
loaded to the browser memory
11
// First option
$(document).ready(function() {
// perform the relevant action after the page is ready to use
});
// Second option
$(function() {
// perform the relevant action after the page is ready to use
});
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
The ready Function
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY SELECTORS
 Selectors allow the selection of page
elements
 Single or multiple elements are
supported
 A selector identifies an HTML element
that will be manipulated later on with
jQuery code
13
www.devconnections.com
JQUERY FUNDAMENTALS
BASIC SELECTORS
 $(„#id‟) – get element by id
 $(„.className‟) – get element/s by a
class name
 $(„elementTagName‟) – get element/s
by a tag name
14
www.devconnections.com
JQUERY FUNDAMENTALS
MORE SELECTOR OPTIONS
 $(„element element‟) - descendants
 $(„element > element‟) - children
 $(„element1+ element2‟) – next element
 $(„element:first‟) - first element
 $(„element:last‟) - last element
15
www.devconnections.com
JQUERY FUNDAMENTALS
MORE SELECTOR OPTIONS
 $(“element[attributeName]”) - has attribute
 $(“element[attributeName=„attributeValue‟]”)
- equals to
 $(“element[attributeName^=„attributeValue‟]”
) - starts with
 $(“element[attrinuteName$=„attributeValue‟]”)
- ends with
 $(“element[attributeName*=„attributeValue‟]”)
- contains
16
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
Selectors
www.devconnections.com
JQUERY FUNDAMENTALS
DOM TRAVERSAL
 jQuery has a variety of DOM traversal
functions
 The functions help to select DOM elements
 Offer a great deal of flexibility
 Allow to act upon multiple sets of elements in a
single chain
 Can be combined with Selectors to create
an extremely powerful selection toolset
18
www.devconnections.com
JQUERY FUNDAMENTALS
TRAVERSING THE DOM
 There are many jQuery functions to
traverse elements
19
.next(expr) // next sibling
.prev(expr) // previous sibling
.siblings(expr) // siblings
.children(expr) // children
.parent(expr) // parent
.find(selector) // find inner elements with the given selector
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
DOM Traversal
www.devconnections.com
JQUERY FUNDAMENTALS
DOM CREATION
 Passing a HTML snippet string as the
parameter to $() will result in new
in-memory DOM element/s
 Then, a jQuery object that refers to the
element/s is created and returned
21
$('<p>My new paragraph</p>').
appendTo('body'); // append a new paragraph to the html
body
$('<a></a>'); // create a new anchor
$('<img />'); // create a new image
$('<input>'); // create a new input type
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
DOM Creation
www.devconnections.com
JQUERY FUNDAMENTALS
DOM MANIPULATION
 jQuery includes ways to manipulate the
DOM
 The manipulation can be:
 To change one of the element‟s attributes
 Set an element's style properties
 And even modify the entire elements
23
www.devconnections.com
JQUERY FUNDAMENTALS
DOM MANIPULATION BASIC FUNCTIONS
 .html(“html”) – set the element/s innerHTML to the
given html
 .text(“text”) – set the element/s textContent to
the given text
 .val(“value”) - set the current value of the
element/s to the given value
 .append, .prepend – append or prepend the
given element to the selected element
 .empty() – remove all children
 .remove() – removes the selected element from
the DOM
24
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
DOM Manipulation
www.devconnections.com
JQUERY FUNDAMENTALS
EVENTS
 jQuery includes cross-browser ways to
bind events to event listeners
 .bind() – event is bound to an element
 .on() – event is bound to an element
 Specific event registration
 .click(callback)
 .dblclick(callback)
 And many other specific event functions
26
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
Working with Events
www.devconnections.com
JQUERY FUNDAMENTALS
AJAX
 Ajax – Asynchronous JavaScript and XML
28
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY AJAX FUNCTIONS
 jQuery allows Ajax requests:
 Allow partial rendering
 Cross-browser support
 Simple API
 GET and POST support
 Load JSON, XML, HTML or even scripts
29
www.devconnections.com
JQUERY FUNDAMENTALS
JQUERY AJAX FUNCTIONS – CONT.
 jQuery provides functions for sending and
receiving data:
 $(selector).load – load HTML data from the server
 $.get() and $.post() – get raw data from the server
 $.getJSON() – get/post and return data in JSON
format
 $.ajax() – provide core functionality for Ajax requests
 jQuery Ajax functions work with web services,
REST interfaces and more
30
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
Ajax
www.devconnections.com
JQUERY FUNDAMENTALS
PLUGINS
 jQuery eco-system includes a big variety of
plugins
 jQueryUI – widgets/animation/UI interaction
 jqGrid – grid based on jQuery
 jqTree – tree based on jQuery
 And more
 You can write your own plugin by assigning it
to $.fn
 Remember to return jQuery in order to allow
chaining
32
www.devconnections.com
JQUERY FUNDAMENTALS
DEMO
Writing a Simple Plugin
www.devconnections.com
JQUERY FUNDAMENTALS
PERFORMANCE TIPS
 Use chaining as much as possible
 DOM manipulation is expensive
 Cache selected elements if you need to use
them later
 Selector performance (from fastest to
slowest):
 Id
 Element
 Class
 Pseudo
34
www.devconnections.com
JQUERY FUNDAMENTALS
QUESTIONS
www.devconnections.com
JQUERY FUNDAMENTALS
SUMMARY
 jQuery is an open source, cross-browser
and lightweight JavaScript library
 It includes a huge plugins eco-system
 It brings a lot of fun for JavaScript
development
www.devconnections.com
JQUERY FUNDAMENTALS
RESOURCES
 Session slide deck and demos –
http://sdrv.ms/1e4J2sM
 jQuery Website – http://www.jquery.com
 My Website – http://www.gilfink.net
 Follow me on Twitter – @gilfink
www.devconnections.com
JQUERY FUNDAMENTALS
THANK YOU
Gil Fink
Senior Architect
gilf@sela.co.il
@gilfink
http://www.gilfink.net

More Related Content

PPTX
jQuery
PPTX
PDF
jQuery - Chapter 3 - Effects
PPT
PPT
Spring Core
PPTX
Javascript 101
PDF
JavaScript Basics and Best Practices - CC FE & UX
PDF
Angular - Chapter 7 - HTTP Services
jQuery
jQuery - Chapter 3 - Effects
Spring Core
Javascript 101
JavaScript Basics and Best Practices - CC FE & UX
Angular - Chapter 7 - HTTP Services

What's hot (20)

PDF
Learning jQuery in 30 minutes
PPT
Advanced Javascript
PDF
REST APIs with Spring
PPT
J query
PPTX
ReactJS presentation.pptx
PPT
JavaScript Tutorial
PPT
JQuery introduction
PPTX
Jquery Complete Presentation along with Javascript Basics
PDF
Javascript
PPTX
reactJS
PPTX
jQuery PPT
PPTX
Spring Security 5
PPTX
Loops PHP 04
PDF
Basics of JavaScript
PDF
jQuery for beginners
PPT
JavaScript - An Introduction
PPTX
React JS - A quick introduction tutorial
PPT
Spring Boot in Action
PDF
Hibernate Presentation
Learning jQuery in 30 minutes
Advanced Javascript
REST APIs with Spring
J query
ReactJS presentation.pptx
JavaScript Tutorial
JQuery introduction
Jquery Complete Presentation along with Javascript Basics
Javascript
reactJS
jQuery PPT
Spring Security 5
Loops PHP 04
Basics of JavaScript
jQuery for beginners
JavaScript - An Introduction
React JS - A quick introduction tutorial
Spring Boot in Action
Hibernate Presentation
Ad

Similar to jQuery Fundamentals (20)

PDF
Introduction to jQuery
ODP
Jquery- One slide completing all JQuery
PDF
PPTX
jQuery basics for Beginners
PPTX
FFW Gabrovo PMG - jQuery
PPTX
Getting Started with jQuery
PPTX
Web technologies-course 11.pptx
PPT
jQuery introduction
PPTX
jQuery
PDF
jQuery in 15 minutes
PDF
J query fundamentals
PPTX
Web Development Introduction to jQuery
PDF
DOM Scripting Toolkit - jQuery
PPTX
Getting started with jQuery
PDF
Learning jquery-in-30-minutes-1195942580702664-3
PDF
Jquery in-15-minutes1421
PPT
J query introduction
KEY
Jquery Fundamentals
PPTX
A to Z about JQuery - Become Newbie to Expert Java Developer
PDF
Jquery tutorial-beginners
Introduction to jQuery
Jquery- One slide completing all JQuery
jQuery basics for Beginners
FFW Gabrovo PMG - jQuery
Getting Started with jQuery
Web technologies-course 11.pptx
jQuery introduction
jQuery
jQuery in 15 minutes
J query fundamentals
Web Development Introduction to jQuery
DOM Scripting Toolkit - jQuery
Getting started with jQuery
Learning jquery-in-30-minutes-1195942580702664-3
Jquery in-15-minutes1421
J query introduction
Jquery Fundamentals
A to Z about JQuery - Become Newbie to Expert Java Developer
Jquery tutorial-beginners
Ad

More from Gil Fink (20)

PDF
Becoming a Tech Speaker
PPTX
Web animation on steroids web animation api
PDF
The Time for Vanilla Web Components has Arrived
PDF
Stencil the time for vanilla web components has arrived
PDF
Stencil the time for vanilla web components has arrived
PDF
Stencil: The Time for Vanilla Web Components has Arrived
PDF
Stencil the time for vanilla web components has arrived
PDF
Being a tech speaker
PDF
Working with Data in Service Workers
PDF
Demystifying Angular Animations
PDF
Redux data flow with angular
PDF
Redux data flow with angular
PDF
Who's afraid of front end databases?
PDF
One language to rule them all type script
PDF
End to-end apps with type script
PDF
Web component driven development
PDF
Web components
PDF
Redux data flow with angular 2
PDF
Biological Modeling, Powered by AngularJS
PDF
Who's afraid of front end databases
Becoming a Tech Speaker
Web animation on steroids web animation api
The Time for Vanilla Web Components has Arrived
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Stencil: The Time for Vanilla Web Components has Arrived
Stencil the time for vanilla web components has arrived
Being a tech speaker
Working with Data in Service Workers
Demystifying Angular Animations
Redux data flow with angular
Redux data flow with angular
Who's afraid of front end databases?
One language to rule them all type script
End to-end apps with type script
Web component driven development
Web components
Redux data flow with angular 2
Biological Modeling, Powered by AngularJS
Who's afraid of front end databases

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25 Week I
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
MIND Revenue Release Quarter 2 2025 Press Release

jQuery Fundamentals