SlideShare a Scribd company logo
13
Most read
14
Most read
16
Most read
By mishraDileep
Agenda
 Introduction, Prerequisite    jQuery Filters
 What is jQuery?               jQuery Attributes
 What is available with        jQuery Events
  jQuery?                       jQuery Callback Functions
 How to use jQuery?            jQuery HTML Manipulation
 jQuery Syntax                 jQuery CSS Manipulation
 jQuery Selectors
Introduction & Prerequisites
 A JavaScript library
 Easy to learn and implement
 jQuery is a fast and concise JavaScript Library that simplifies
    HTML document traversing
    Event handling
    Animation
    AJAX Interaction for rapid web development


 Prerequisites
    HTML
    CSS
    JavaScript
What is jQuery?
 A library of JavaScript Functions.
 A lightweight "write less, do more" JavaScript library.
 The jQuery library contains the following features:
         HTML element selections
         HTML element manipulation
         CSS manipulation
         HTML event functions
         JavaScript Effects and animations
         HTML DOM traversal and modification
         AJAX
         Utilities

 An open source project, maintained by group of developers
  with active support base and well written documentation
What is available with jQuery
 Cross Browser support     JavaScript Animation
 AJAX Functions            Hundreds of plug-ins for
 CSS functions              pre-built user interfaces,
                             advanced animation and
 DOM Manipulation
                             form validation etc …
 DOM Traversing
                            Expandable using custom
 Attribute Manipulation     plug-ins
 Event detection and       Small footprint
 handling
How to use jQuery?
 A single JavaScript file, containing all the jQuery methods.

 Add the following code into your html/jsp page and call the jQuery APIs.
          <head>
           <script type="text/javascript" src="jquery.js"></script>
           </head>
 For Example
          <html>
           <head>
           <script type="text/javascript" src="jquery.js"></script>
           <script type="text/javascript">
           $(document).ready(function(){
            $("button").click(function(){
               $("p").hide();
            });
           });
           </script>
           </head>
           <body>
           <h2>This is a heading</h2>
           <p>This is a paragraph.</p>
           <p>This is another paragraph.</p>
           <button>Click me</button>
           </body>
           </html>
How to use jQuery?Cont…
 In order to use jQuery you need to load it.
 You can include it locally on your own server:
    <script src="/js/jquery.js">
 Or use one of the CDN's made available:
    ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
    ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js
    CDN's are Gzipped and minified
jQuery Syntax
 With jQuery you select (query) HTML elements and
  perform "actions" on them.
 jQuery Syntax Examples
      $(this).hide()
      $("#test").hide()
      $("p").hide()
      $(".test").hide()

 Basic syntax is: $(selector).action()
    A dollar sign to define jQuery
    A (selector) to "query (or find)" HTML elements
    A jQuery action() to be performed on the element(s)
jQuery Selectors
 To select HTML elements (or groups of elements) by
  element name, attribute name or by content.

 jQuery Element Selectors
    Uses CSS selectors to select HTML elements.
       $("p“)
       $("p.intro“)
       $("p#demo“)
jQuery Selectors
 jQuery Attribute Selectors
    jQuery uses XPath expressions to select elements with given
     attributes.
    $("[href ]“)
    $("[href='#']")
    $("[href!='#']“).
    $("[href$='.jpg']“)
 jQuery CSS Selectors
    jQuery CSS selectors can be used to change CSS properties for
     HTML elements.
    For Ex :
        $("p").css("background-color","yellow");
jQuery Selectors
 Few samples for the selectors
Syntax                Description
$(this)               Current HTML element
$("p")                All <p> elements
$("p.intro")          All <p> elements with class="intro"
$(".intro")           All elements with class="intro"
$("#intro")           The first element with id="intro"
$("ul li:first")      The first <li> element of each <ul>
$("[href$='.jpg']")   All elements with an href attribute that ends with ".jpg"
$("div#intro          All elements with class="head" inside a <div> element with
.head")               id="intro"
jQuery Filters
 First paragraph – p:first
 Last list item – li:last
 Fourth link – a:nth(3)
 Fourth Div – div:eq(3)
 Every other Paragraph – p:odd or p:even
 Every link after/upto 4th – a:gt(3) or a:lt(4)
 Links that contain word like click – a:contains(“click”)
 All radio inputs with in first form - $(“input:radio”,
  documents.forms[0])
jQuery Attributes
 Read
    $(#image).attr(“src”);
 Set
    $(#image).attr(“src” , “images/jquery1.jpg”);
 Multiple Set
    $(#image).attr({src: “images/jquery1.jpg” , alt: “jQuery”});
 Set Class
    $(p:last).addClass(“selected”);
 Read/Set Html
    $(#id).html() & $(#id).html(“value”);
jQuery Events
 The jQuery event handling methods are core functions in jQuery.

 For Example
       <html>
        <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
         $("button").click(function(){
            $("p").hide();
         });
        });
        </script>
        </head>
        <body>
        <h2>This is a heading</h2>
        <p>This is a paragraph.</p>
        <p>This is another paragraph.</p>
        <button>Click me</button>
        </body></html>
jQuery Callback Functions
 A callback function is executed after the current
  animation (effect) is finished.
 Syntax
   $(selector).hide(speed,callback)
 For Ex:
    $("p").hide(1000,function(){
      alert("The paragraph is now hidden");
     });
jQuery HTML Manipulation
 jQuery can manipulate the HTML elements and
  attributes
 Changing HTML Content
   $(selector).html(content)
 Adding HTML content
    $(selector).append(content)
    $(selector).prepend(content)
    $(selector).after(content)
    $(selector).before(content)
jQuery HTML Manipulation
  jQuery HTML Manipulation Methods

Function                      Description

$(selector).html(content)     Changes the (inner) HTML of selected elements

                              Appends content to the (inner) HTML of selected
$(selector).append(content)
                              elements

$(selector).after(content)    Adds HTML after selected elements
jQuery CSS Manipulation
 jQuery css() Method
    css(name) - Return CSS property value
    css(name,value) - Set CSS property and value
    css({properties}) - Set multiple CSS properties and values
 Examples
    Return CSS Property
        $(this).css("background-color");
    Set CSS Property & value
      $("p").css("background-color"," yellow");
    Set Multiple values in CSS
      $("p").css({"background-color":"yellow","font-size":"200%"});
    Size Manipulation
      $("#div1").height("200px"); $("#div2").width("300px");
jQuery CSS Manipulation
 Offset
   $(this).offset().left
   $(this).offset().top


 Position
    $(this).position().left
    $(this).position().top
jQuery CSS Manipulation
 jQuery CSS Manipulation Methods
CSS Properties                  Description

                                Get the style property value of the first
$(selector).css(name)
                                matched element

                                Set the value of one style property for
$(selector).css(name,value)
                                matched elements

                                Set multiple style properties for
$(selector).css({properties})
                                matched elements

$(selector).height(value)       Set the height of matched elements
$(selector).width(value)        Set the width of matched elements
jQuery

More Related Content

PPTX
jQuery
PPT
Joomla
PPTX
jQuery PPT
PPTX
Blockchain Based voting system PPT.pptx
PDF
Bootstrap
PDF
Web Development with HTML5, CSS3 & JavaScript
PPT
Unit 1 python (2021 r)
PPTX
Review of Literature
jQuery
Joomla
jQuery PPT
Blockchain Based voting system PPT.pptx
Bootstrap
Web Development with HTML5, CSS3 & JavaScript
Unit 1 python (2021 r)
Review of Literature

What's hot (20)

PDF
jQuery for beginners
PPT
Introduction to Javascript
PPT
PHP - Introduction to PHP AJAX
PDF
Basics of JavaScript
PPT
PPTX
Ajax
PPTX
Ajax ppt - 32 slides
PPTX
Lab #2: Introduction to Javascript
PPT
Asynchronous JavaScript & XML (AJAX)
PPT
JavaScript - An Introduction
PPT
Oops concepts in php
PPT
JQuery introduction
PPTX
Dom(document object model)
PPTX
What is Ajax technology?
PPTX
Java script
PPT
Ajax Ppt
PDF
Html / CSS Presentation
PPTX
Basic HTML
jQuery for beginners
Introduction to Javascript
PHP - Introduction to PHP AJAX
Basics of JavaScript
Ajax
Ajax ppt - 32 slides
Lab #2: Introduction to Javascript
Asynchronous JavaScript & XML (AJAX)
JavaScript - An Introduction
Oops concepts in php
JQuery introduction
Dom(document object model)
What is Ajax technology?
Java script
Ajax Ppt
Html / CSS Presentation
Basic HTML
Ad

Similar to jQuery (20)

PPTX
Jquery Complete Presentation along with Javascript Basics
PDF
jQuery Rescue Adventure
PDF
Introduzione JQuery
PPTX
How to increase Performance of Web Application using JQuery
PDF
PPT
Intro to jQuery
PPT
PPTX
presentation_jquery_ppt.pptx
PPT
J Query Public
PDF
Learning jQuery made exciting in an interactive session by one of our team me...
PDF
Advanced JQuery Mobile tutorial with Phonegap
PPTX
PPTX
jQuery Presentasion
PDF
Jquery presentation
PPT
J query
PDF
Introduction to jQuery
PPT
J query b_dotnet_ug_meet_12_may_2012
PPTX
Introduction to jQuery
PDF
jQuery Basic API
Jquery Complete Presentation along with Javascript Basics
jQuery Rescue Adventure
Introduzione JQuery
How to increase Performance of Web Application using JQuery
Intro to jQuery
presentation_jquery_ppt.pptx
J Query Public
Learning jQuery made exciting in an interactive session by one of our team me...
Advanced JQuery Mobile tutorial with Phonegap
jQuery Presentasion
Jquery presentation
J query
Introduction to jQuery
J query b_dotnet_ug_meet_12_may_2012
Introduction to jQuery
jQuery Basic API
Ad

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...

jQuery

  • 2. Agenda  Introduction, Prerequisite  jQuery Filters  What is jQuery?  jQuery Attributes  What is available with  jQuery Events jQuery?  jQuery Callback Functions  How to use jQuery?  jQuery HTML Manipulation  jQuery Syntax  jQuery CSS Manipulation  jQuery Selectors
  • 3. Introduction & Prerequisites  A JavaScript library  Easy to learn and implement  jQuery is a fast and concise JavaScript Library that simplifies  HTML document traversing  Event handling  Animation  AJAX Interaction for rapid web development  Prerequisites  HTML  CSS  JavaScript
  • 4. What is jQuery?  A library of JavaScript Functions.  A lightweight "write less, do more" JavaScript library.  The jQuery library contains the following features:  HTML element selections  HTML element manipulation  CSS manipulation  HTML event functions  JavaScript Effects and animations  HTML DOM traversal and modification  AJAX  Utilities  An open source project, maintained by group of developers with active support base and well written documentation
  • 5. What is available with jQuery  Cross Browser support  JavaScript Animation  AJAX Functions  Hundreds of plug-ins for  CSS functions pre-built user interfaces, advanced animation and  DOM Manipulation form validation etc …  DOM Traversing  Expandable using custom  Attribute Manipulation plug-ins  Event detection and  Small footprint handling
  • 6. How to use jQuery?  A single JavaScript file, containing all the jQuery methods.  Add the following code into your html/jsp page and call the jQuery APIs.  <head> <script type="text/javascript" src="jquery.js"></script> </head>  For Example  <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Click me</button> </body> </html>
  • 7. How to use jQuery?Cont…  In order to use jQuery you need to load it.  You can include it locally on your own server:  <script src="/js/jquery.js">  Or use one of the CDN's made available:  ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js  ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js  CDN's are Gzipped and minified
  • 8. jQuery Syntax  With jQuery you select (query) HTML elements and perform "actions" on them.  jQuery Syntax Examples  $(this).hide()  $("#test").hide()  $("p").hide()  $(".test").hide()  Basic syntax is: $(selector).action()  A dollar sign to define jQuery  A (selector) to "query (or find)" HTML elements  A jQuery action() to be performed on the element(s)
  • 9. jQuery Selectors  To select HTML elements (or groups of elements) by element name, attribute name or by content.  jQuery Element Selectors  Uses CSS selectors to select HTML elements.  $("p“)  $("p.intro“)  $("p#demo“)
  • 10. jQuery Selectors  jQuery Attribute Selectors  jQuery uses XPath expressions to select elements with given attributes.  $("[href ]“)  $("[href='#']")  $("[href!='#']“).  $("[href$='.jpg']“)  jQuery CSS Selectors  jQuery CSS selectors can be used to change CSS properties for HTML elements.  For Ex :  $("p").css("background-color","yellow");
  • 11. jQuery Selectors  Few samples for the selectors Syntax Description $(this) Current HTML element $("p") All <p> elements $("p.intro") All <p> elements with class="intro" $(".intro") All elements with class="intro" $("#intro") The first element with id="intro" $("ul li:first") The first <li> element of each <ul> $("[href$='.jpg']") All elements with an href attribute that ends with ".jpg" $("div#intro All elements with class="head" inside a <div> element with .head") id="intro"
  • 12. jQuery Filters  First paragraph – p:first  Last list item – li:last  Fourth link – a:nth(3)  Fourth Div – div:eq(3)  Every other Paragraph – p:odd or p:even  Every link after/upto 4th – a:gt(3) or a:lt(4)  Links that contain word like click – a:contains(“click”)  All radio inputs with in first form - $(“input:radio”, documents.forms[0])
  • 13. jQuery Attributes  Read  $(#image).attr(“src”);  Set  $(#image).attr(“src” , “images/jquery1.jpg”);  Multiple Set  $(#image).attr({src: “images/jquery1.jpg” , alt: “jQuery”});  Set Class  $(p:last).addClass(“selected”);  Read/Set Html  $(#id).html() & $(#id).html(“value”);
  • 14. jQuery Events  The jQuery event handling methods are core functions in jQuery.  For Example  <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Click me</button> </body></html>
  • 15. jQuery Callback Functions  A callback function is executed after the current animation (effect) is finished.  Syntax  $(selector).hide(speed,callback)  For Ex:  $("p").hide(1000,function(){ alert("The paragraph is now hidden"); });
  • 16. jQuery HTML Manipulation  jQuery can manipulate the HTML elements and attributes  Changing HTML Content  $(selector).html(content)  Adding HTML content  $(selector).append(content)  $(selector).prepend(content)  $(selector).after(content)  $(selector).before(content)
  • 17. jQuery HTML Manipulation  jQuery HTML Manipulation Methods Function Description $(selector).html(content) Changes the (inner) HTML of selected elements Appends content to the (inner) HTML of selected $(selector).append(content) elements $(selector).after(content) Adds HTML after selected elements
  • 18. jQuery CSS Manipulation  jQuery css() Method  css(name) - Return CSS property value  css(name,value) - Set CSS property and value  css({properties}) - Set multiple CSS properties and values  Examples  Return CSS Property  $(this).css("background-color");  Set CSS Property & value  $("p").css("background-color"," yellow");  Set Multiple values in CSS  $("p").css({"background-color":"yellow","font-size":"200%"});  Size Manipulation  $("#div1").height("200px"); $("#div2").width("300px");
  • 19. jQuery CSS Manipulation  Offset  $(this).offset().left  $(this).offset().top  Position  $(this).position().left  $(this).position().top
  • 20. jQuery CSS Manipulation  jQuery CSS Manipulation Methods CSS Properties Description Get the style property value of the first $(selector).css(name) matched element Set the value of one style property for $(selector).css(name,value) matched elements Set multiple style properties for $(selector).css({properties}) matched elements $(selector).height(value) Set the height of matched elements $(selector).width(value) Set the width of matched elements