SlideShare a Scribd company logo
Compiled By: Seble N
 What is jQuery?
 jQuery is a lightweight, "write less, do more", JavaScript library.
 The purpose of jQuery is to make it much easier to use JavaScript on
your website
 jQuery takes a lot of common tasks that require many lines of
JavaScript code to accomplish, and wraps them into methods that you
can call with a single line of code
 The jQuery library contains the following features:
 HTML/DOM manipulation
 CSS manipulation
 HTML event methods
 Effects and animations
 AJAX, Utilities
 In addition, jQuery has plugins for almost any task out
there.
 There are two ways to start using jQuery on
your web site
 You can:
 Download the jQuery library from jQuery.com
 Include jQuery from a CDN, like Google
 There are two versions of jQuery available for downloading:
 Production version - this is for your live website because it has been
minified and compressed
 Development version - this is for testing and development
(uncompressed and readable code)
 Both versions can be downloaded from jQuery.com.
 The jQuery library is a single JavaScript file,
and you reference it with the HTML <script>
tag
<head>
<script src="jquery-1.11.3.min.js"></script>
</head>
 jQuery CDN
 If you don't want to download and host jQuery yourself, you can include it from a
CDN (Content Delivery Network).
 Both Google and Microsoft host jQuery.
 To use jQuery from Google or Microsoft, use one of the following:
 Google CDN:
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
 Microsoft CDN:
 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
 The jQuery syntax is tailor made for selecting HTML elements and
performing some action on the element(s)
 Basic syntax is: $(selector).action()
 A $ sign to define/access jQuery
 A (selector) to "query (or find)" HTML elements
 A jQuery action() to be performed on the element(s)
 Examples:
 $(this).hide() - hides the current element.
 $("p").hide() - hides all <p> elements.
 $("#test").hide() - hides the element with id="test".
 All jQuery methods are usually inside a document ready
event:
 $(document).ready(function(){
//jQuery methods go here...
});
 OR
 $(function(){
// jQuery methods go here...
});
 This helps to prevent any jQuery code from running before
the document is finished loading (is ready)
 jQuery selectors are used to "find" (or select) HTML
elements based on their id, classes, types ….
 It's based on the existing CSS Selectors, and in
addition, it has some own custom selectors.
 All selectors in jQuery start with the dollar sign and
parentheses: $()
 The element Selector
 selects elements based on the element name.
 to select all <p> elements on a page like this:
 $("p")
 The #id Selector
 uses the id attribute of an HTML tag to find the specific element.
 to find an element with a specific id, write a hash character, followed by the id of the
HTML element:
 $("#test")
 The .class Selector
 finds elements with a specific class.
 to find elements with a specific class, write a period character, followed by the name
of the class:
 $(".test")
• Other jQuery Selectors
 $("*"): Selects all elements
 $("p.intro"): Selects all <p> elements with class="intro"
 $("ul li:first"): Selects the first <li> element of the first <ul>
 $("ul li:first-child"): Selects the first <li> element of every <ul>
 $("[href]"): Selects all elements with an href attribute
 $("a[target='_blank']"): Selects all <a> elements with a target attribute value equal to "_blank"
 $("a[target!='_blank']"): Selects all <a> elements with a target attribute value NOT equal to "_blank"
 $(":button"): Selects all <button> elements and <input> elements of type="button"
 $("tr:even"): Selects all even <tr> elements
 jQuery is tailor-made to respond to events in an HTML page
 jQuery Syntax For Event Methods
 To assign a click event to all paragraphs on a page, you can do this:
 $("p").click();
 The next step is to define what should happen when the event fires. You must pass a function
to the event:
 $("p").click(function(){
// action goes here!!
});
 Using the on() Method
 $("p").on("click", function(){
//action goes here
});
Example:
$("p").click(function(){
$(this).hide();
});
Introduction to jQuery
 Used to hide and show HTML elements
 Syntax:
$(selector).hide(speed,callback);
$(selector).show(speed,callback);
$(selector).toggle(speed,callback);
 The optional speed parameter specifies the speed of the hiding/showing, and
can take the following values: "slow", "fast", or milliseconds.
 The optional callback parameter is a function to be executed after the hide() ,
show() or toggle() method completes
Introduction to jQuery
 With jQuery you can fade an element in and out of visibility.
 jQuery has the following fade methods:
 fadeIn(speed,callback) is used to fade in a hidden element.
 fadeOut(speed,callback) is used to fade out a visible element
 fadeToggle(speed,callback) toggles between the fadeIn() and fadeOut()
methods
 fadeTo(speed,callback) allows fading to a given opacity (value between 0 and
1)
Introduction to jQuery
 With jQuery you can create a sliding effect on
elements.
 jQuery has the following slide methods:
 slideDown(speed, callback) is used to slide down an
element
 slideUp(speed, callback) is used to slide up an element
 slideToggle()
Introduction to jQuery
 jQuery offers the follwing methods for DOM
manipulation:
 text() - Sets or returns the text content of selected elements
 html() - Sets or returns the content of selected elements
(including HTML markup)
 val() - Sets or returns the value of form fields
 attr() – Sets or returns attribute values
Introduction to jQuery
 With jQuery, it is easy to add new elements/content.
 Four jQuery methods that are used to add new content:
 append() - Inserts content at the end of the selected elements
 prepend() - Inserts content at the beginning of the selected
elements
 after() - Inserts content after the selected elements
 before() - Inserts content before the selected elements
Introduction to jQuery
 To remove elements and content, there are two jQuery
methods:
 remove() - Removes the selected element (and its child
elements)
 also accepts one parameter, which allows you to filter the elements to
be removed.
 The parameter can be any of the jQuery selector syntaxes.
 empty() - Removes the child elements from the selected
element
Introduction to jQuery
 jQuery has several methods for CSS manipulation. We will look at the
following methods:
 addClass() - Adds one or more classes to the selected elements
 removeClass() - Removes one or more classes from the selected elements
 toggleClass() - Toggles between adding/removing classes from the selected
elements
 css() - Sets or returns one or more style properties for the selected elements
 Syntax: css("propertyname"); & css("propertyname","value");
Introduction to jQuery
 With jQuery, you can chain together actions/methods
 Chaining allows us to run multiple jQuery methods (on the same
element) within a single statement
 This way, browsers do not have to find the same element(s) more than once
 To chain an action, you simply append the action to the previous
action using a dot

More Related Content

What's hot (20)

PPTX
Jquery
Zoya Shaikh
 
PPTX
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
PDF
jQuery - Chapter 4 - DOM Handling
WebStackAcademy
 
PPT
J Query Public
pradeepsilamkoti
 
PPT
Intro to jQuery
Alan Hecht
 
PPTX
jQuery Presentasion
Mohammad Usman
 
PPTX
JQuery
Jacob Nelson
 
PPTX
Jquery
Elite outreach co
 
PPTX
Jquery
Pankaj Srivastava
 
PDF
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
PDF
JavaScript
Bharti Gupta
 
PPTX
J Query The Write Less Do More Javascript Library
rsnarayanan
 
PPTX
JQuery Overview
Mahmoud Tolba
 
PDF
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 
PPTX
Jquery introduction
musrath mohammad
 
PPT
Introduction to JQuery
MobME Technical
 
PPTX
Css Selectors
Igor Ognichenko
 
PPTX
Test automation with selenide
Isuru Madanayaka
 
Jquery
Zoya Shaikh
 
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
jQuery - Chapter 4 - DOM Handling
WebStackAcademy
 
J Query Public
pradeepsilamkoti
 
Intro to jQuery
Alan Hecht
 
jQuery Presentasion
Mohammad Usman
 
JQuery
Jacob Nelson
 
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
JavaScript
Bharti Gupta
 
J Query The Write Less Do More Javascript Library
rsnarayanan
 
JQuery Overview
Mahmoud Tolba
 
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 
Jquery introduction
musrath mohammad
 
Introduction to JQuery
MobME Technical
 
Css Selectors
Igor Ognichenko
 
Test automation with selenide
Isuru Madanayaka
 

Similar to Introduction to jQuery (20)

PPTX
presentation_jquery_ppt.pptx
azz71
 
PPTX
Unit-III_JQuery.pptx engineering subject for third year students
MARasheed3
 
PDF
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
RAVALCHIRAG1
 
PPTX
Web technologies-course 11.pptx
Stefan Oprea
 
PPTX
JQuery_and_Ajax.pptx
AditiPawale1
 
PPTX
jQuery
Dileep Mishra
 
PPT
J query
Manav Prasad
 
PPTX
jQuery besic
Syeful Islam
 
PDF
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
Edureka!
 
PPTX
J query
Ramakrishna kapa
 
PDF
Introduzione JQuery
orestJump
 
PPTX
Unit3.pptx
AnamikaRai59
 
PPT
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
shubhangimalas1
 
PPT
J query presentation
sawarkar17
 
PPT
J query presentation
akanksha17
 
PDF
Javascript libraries
Dumindu Pahalawatta
 
PDF
Advanced JQuery Mobile tutorial with Phonegap
Rakesh Jha
 
PDF
Introduction to jQuery
Zeeshan Khan
 
PPT
Jquery presentation
Narendra Dabhi
 
presentation_jquery_ppt.pptx
azz71
 
Unit-III_JQuery.pptx engineering subject for third year students
MARasheed3
 
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
RAVALCHIRAG1
 
Web technologies-course 11.pptx
Stefan Oprea
 
JQuery_and_Ajax.pptx
AditiPawale1
 
J query
Manav Prasad
 
jQuery besic
Syeful Islam
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
Edureka!
 
Introduzione JQuery
orestJump
 
Unit3.pptx
AnamikaRai59
 
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
shubhangimalas1
 
J query presentation
sawarkar17
 
J query presentation
akanksha17
 
Javascript libraries
Dumindu Pahalawatta
 
Advanced JQuery Mobile tutorial with Phonegap
Rakesh Jha
 
Introduction to jQuery
Zeeshan Khan
 
Jquery presentation
Narendra Dabhi
 
Ad

More from Seble Nigussie (9)

PDF
Fundamentals of programming with C++
Seble Nigussie
 
PDF
Introduction to JSON & Ajax
Seble Nigussie
 
PDF
Introduction to Javascript
Seble Nigussie
 
PDF
Introduction to Bootstrap
Seble Nigussie
 
PDF
Flexbox, Grid and Sass
Seble Nigussie
 
PDF
Introduction to CSS3
Seble Nigussie
 
PDF
Introduction to HTML
Seble Nigussie
 
PDF
Introduction to HTTP
Seble Nigussie
 
PDF
Introduction to Microprocessors
Seble Nigussie
 
Fundamentals of programming with C++
Seble Nigussie
 
Introduction to JSON & Ajax
Seble Nigussie
 
Introduction to Javascript
Seble Nigussie
 
Introduction to Bootstrap
Seble Nigussie
 
Flexbox, Grid and Sass
Seble Nigussie
 
Introduction to CSS3
Seble Nigussie
 
Introduction to HTML
Seble Nigussie
 
Introduction to HTTP
Seble Nigussie
 
Introduction to Microprocessors
Seble Nigussie
 
Ad

Recently uploaded (20)

PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PDF
John Keats introduction and list of his important works
vatsalacpr
 
PPTX
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
John Keats introduction and list of his important works
vatsalacpr
 
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 

Introduction to jQuery

  • 2.  What is jQuery?  jQuery is a lightweight, "write less, do more", JavaScript library.  The purpose of jQuery is to make it much easier to use JavaScript on your website  jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code
  • 3.  The jQuery library contains the following features:  HTML/DOM manipulation  CSS manipulation  HTML event methods  Effects and animations  AJAX, Utilities  In addition, jQuery has plugins for almost any task out there.
  • 4.  There are two ways to start using jQuery on your web site  You can:  Download the jQuery library from jQuery.com  Include jQuery from a CDN, like Google
  • 5.  There are two versions of jQuery available for downloading:  Production version - this is for your live website because it has been minified and compressed  Development version - this is for testing and development (uncompressed and readable code)  Both versions can be downloaded from jQuery.com.
  • 6.  The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag <head> <script src="jquery-1.11.3.min.js"></script> </head>
  • 7.  jQuery CDN  If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).  Both Google and Microsoft host jQuery.  To use jQuery from Google or Microsoft, use one of the following:  Google CDN:  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  Microsoft CDN:  <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
  • 8.  The jQuery syntax is tailor made for selecting HTML elements and performing some action on the element(s)  Basic syntax is: $(selector).action()  A $ sign to define/access jQuery  A (selector) to "query (or find)" HTML elements  A jQuery action() to be performed on the element(s)  Examples:  $(this).hide() - hides the current element.  $("p").hide() - hides all <p> elements.  $("#test").hide() - hides the element with id="test".
  • 9.  All jQuery methods are usually inside a document ready event:  $(document).ready(function(){ //jQuery methods go here... });  OR  $(function(){ // jQuery methods go here... });  This helps to prevent any jQuery code from running before the document is finished loading (is ready)
  • 10.  jQuery selectors are used to "find" (or select) HTML elements based on their id, classes, types ….  It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.  All selectors in jQuery start with the dollar sign and parentheses: $()
  • 11.  The element Selector  selects elements based on the element name.  to select all <p> elements on a page like this:  $("p")  The #id Selector  uses the id attribute of an HTML tag to find the specific element.  to find an element with a specific id, write a hash character, followed by the id of the HTML element:  $("#test")  The .class Selector  finds elements with a specific class.  to find elements with a specific class, write a period character, followed by the name of the class:  $(".test")
  • 12. • Other jQuery Selectors  $("*"): Selects all elements  $("p.intro"): Selects all <p> elements with class="intro"  $("ul li:first"): Selects the first <li> element of the first <ul>  $("ul li:first-child"): Selects the first <li> element of every <ul>  $("[href]"): Selects all elements with an href attribute  $("a[target='_blank']"): Selects all <a> elements with a target attribute value equal to "_blank"  $("a[target!='_blank']"): Selects all <a> elements with a target attribute value NOT equal to "_blank"  $(":button"): Selects all <button> elements and <input> elements of type="button"  $("tr:even"): Selects all even <tr> elements
  • 13.  jQuery is tailor-made to respond to events in an HTML page  jQuery Syntax For Event Methods  To assign a click event to all paragraphs on a page, you can do this:  $("p").click();  The next step is to define what should happen when the event fires. You must pass a function to the event:  $("p").click(function(){ // action goes here!! });  Using the on() Method  $("p").on("click", function(){ //action goes here }); Example: $("p").click(function(){ $(this).hide(); });
  • 15.  Used to hide and show HTML elements  Syntax: $(selector).hide(speed,callback); $(selector).show(speed,callback); $(selector).toggle(speed,callback);  The optional speed parameter specifies the speed of the hiding/showing, and can take the following values: "slow", "fast", or milliseconds.  The optional callback parameter is a function to be executed after the hide() , show() or toggle() method completes
  • 17.  With jQuery you can fade an element in and out of visibility.  jQuery has the following fade methods:  fadeIn(speed,callback) is used to fade in a hidden element.  fadeOut(speed,callback) is used to fade out a visible element  fadeToggle(speed,callback) toggles between the fadeIn() and fadeOut() methods  fadeTo(speed,callback) allows fading to a given opacity (value between 0 and 1)
  • 19.  With jQuery you can create a sliding effect on elements.  jQuery has the following slide methods:  slideDown(speed, callback) is used to slide down an element  slideUp(speed, callback) is used to slide up an element  slideToggle()
  • 21.  jQuery offers the follwing methods for DOM manipulation:  text() - Sets or returns the text content of selected elements  html() - Sets or returns the content of selected elements (including HTML markup)  val() - Sets or returns the value of form fields  attr() – Sets or returns attribute values
  • 23.  With jQuery, it is easy to add new elements/content.  Four jQuery methods that are used to add new content:  append() - Inserts content at the end of the selected elements  prepend() - Inserts content at the beginning of the selected elements  after() - Inserts content after the selected elements  before() - Inserts content before the selected elements
  • 25.  To remove elements and content, there are two jQuery methods:  remove() - Removes the selected element (and its child elements)  also accepts one parameter, which allows you to filter the elements to be removed.  The parameter can be any of the jQuery selector syntaxes.  empty() - Removes the child elements from the selected element
  • 27.  jQuery has several methods for CSS manipulation. We will look at the following methods:  addClass() - Adds one or more classes to the selected elements  removeClass() - Removes one or more classes from the selected elements  toggleClass() - Toggles between adding/removing classes from the selected elements  css() - Sets or returns one or more style properties for the selected elements  Syntax: css("propertyname"); & css("propertyname","value");
  • 29.  With jQuery, you can chain together actions/methods  Chaining allows us to run multiple jQuery methods (on the same element) within a single statement  This way, browsers do not have to find the same element(s) more than once  To chain an action, you simply append the action to the previous action using a dot