SlideShare a Scribd company logo
1 of 27
iFour ConsultancyJQuery
 jQuery is a JavaScript Library.
 jQuery greatly simplifies JavaScript programming.
 jQuery is a lightweight, "write less, do more", JavaScript library.
 jQuery simplifies HTML document traversing, event handling, animating, and
Ajax interactions for rapid web development.
 The purpose of jQuery is to make it much easier to use JavaScript on your
website.
Introduction to JQuery
Custom Online Shop Developershttp://www.ifourtechnolab.com
 There are lots of other JavaScript frameworks out there, but jQuery seems to be
the most popular, and also the most extendable.
 Many of the biggest companies on the Web use jQuery, such as:
• Google
• Microsoft
• IBM
• Netflix
Advantages of jQuery
Custom Online Shop Developershttp://www.ifourtechnolab.com
 There are several ways to start using jQuery on your web site.
• 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
• Development version
 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.
How to Install
Custom Online Shop Developershttp://www.ifourtechnolab.com
jQuery Syntax
 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).
 The Document Ready event is used to prevent any jQuery code from running
before the document is finished loading (is ready).
 It is good practice to wait for the document to be fully loaded and ready before
working with it.
Custom Online Shop Developershttp://www.ifourtechnolab.com
Enable jQuery in your page
• jQuery can be enabled in your page by including
reference to jQuery library file
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
• Introduce a jQuery function by using the below below given function.
$(document).ready(function(){
//Script goes here
});
OR
$(function(){
//Script goes here
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
JavaScript vs jQuery
• Example 1 - Hide an element with id "textbox“
//javascript
document.getElementById('textbox').style.display = "none";
//jQuery
$(' #textbox' ).hide();
• Example 2 - Create a <h1> tag with "my text“
//javascript
var h1 = document.CreateElement("h1");
h1.innerHTML = "my text";
document.getElementsByTagName('body')[0].appendChild(h1);
//jQuery
$(' body').append( $("<h1/>").html("my text") ;
Custom Online Shop Developershttp://www.ifourtechnolab.com
 jQuery selectors are one of the most important parts of the jQuery library.
 jQuery selectors allow you to select and manipulate HTML element(s).
 jQuery selectors are used to "find" (or select) HTML elements based on their
id, classes, types, attributes, values of attributes and much more.
 The jQuery element selector selects elements based on the element name.
 The jQuery #id selector uses the id attribute of an HTML tag to find the
specific element.
 The jQuery class selector finds elements with a specific class.
jQuery Selectors
Custom Online Shop Developershttp://www.ifourtechnolab.com
Basic selectors
• TagName
document.getElementsByTagName("tagName"); (javascript)
$("tagName") - $("div"), $("p"), $("div"),.....
• Tag ID
document.getElementById("id"); (javascript)
$("#id") - $("#name"), $("#address")
• Tag Class
document.getElementsByClassName("className"); (javascript)
$(".className") - $(".comment"), $(".code")
• To select all elements - $("*")
Custom Online Shop Developershttp://www.ifourtechnolab.com
Positional Selectors
Syntax: Examples:
$("selector:first") $("p:first")
$("selector:last") $("p:last")
$("selector:odd") $("p:odd")
$("selector:even") $("p:even")
$("selector:eq(i)") $("p:eq(1)")
$("selector:gt(i)") $("p:gt(1)")
$("selector:lt(i)") $("p:lt(1)")
Custom Online Shop Developershttp://www.ifourtechnolab.com
Form Element(Custom) Selectors
$("selector:visible") $("selector:input")
$("selector:hidden") $("selector:text")
$("selector:disabled") $("selector:password")
$("selector:enabled") $("selector:radio")
$("selector:checked") $("selector:checkbox")
$("selector:selected") $("selector:submit")
$("selector:header") $("selector:reset")
$("selector:animated") $("selector:image")
$("selector:not(selector:not)") $("selector:file")
$("selector:button")
Custom Online Shop Developershttp://www.ifourtechnolab.com
Retrieve, Set and Remove attribute
Syntax: Examples:
• $("selector").attr("name") • $("img").attr("src")
• $("selector").attr("key","val") • $("p").attr("class","source")
• $("selector").attr("key",fn()) • $("img").attr("height",calHt())
• $("selector").attr(properties) • $("img").attr({"src":"/path/","title" : "My Img"});
• $("selector").removeAttr(attr) • $("div").removeAttr("class“)
Custom Online Shop Developershttp://www.ifourtechnolab.com
Class, HTML, Text, Value - Functions
• $("selector").hasClass("className")
• $("selector").addClass("className")
• $("selector").removeClass("className")
• $("selector").toggleClass("className")
• $("selector").html()
• $("selector").html("html code")
• $("selector").text()
• $("selector").text("text content")
• $("selector").val()
• $("selector").val("value")
Custom Online Shop Developershttp://www.ifourtechnolab.com
 All the different visitor's actions that a web page can respond to are called events.
 An event represents the precise moment when something happens.
 Examples:
• moving a mouse over an element
• selecting a radio button
• clicking on an element
 The term "fires/fired" is often used with events. Example: "The keypress event is
fired, the moment you press a key".
Events
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 click()
• The click() method attaches an event handler function to an HTML
element.
• The function is executed when the user clicks on the HTML element.
• The following example says: When a click event fires on a <p> element;
hide the current <p> element:
• Example: $("p").click(function(){
$(this).hide();
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 dblclick()
• The dblclick() method attaches an event handler function to an HTML
element.
• The function is executed when the user double-clicks on the HTML
element:
• Example: $("p").dblclick(function(){
$(this).hide();
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 mouseenter()
• The mouseenter() method attaches an event handler function to an
HTML element.
• The function is executed when the mouse pointer enters the HTML
element:
• Example: $("#p1").mouseenter(function(){
alert("You entered p1!");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 mouseleave()
• The mouseleave() method attaches an event handler function to an
HTML element.
• The function is executed when the mouse pointer leaves the HTML
element:
• Example: $("#p1").mouseleave(function(){
alert("Bye! You now leave p1!");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 mousedown()
• The mousedown() method attaches an event handler function to an
HTML element.
• The function is executed, when the left, middle or right mouse button is
pressed down, while the mouse is over the HTML element:
• Example: $("#p1").mousedown(function(){
alert("Mouse down over p1!");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 mouseup()
• The mouseup() method attaches an event handler function to an HTML
element.
• The function is executed, when the left, middle or right mouse button is
released, while the mouse is over the HTML element:
• Example: $("#p1").mouseup(function(){
alert("Mouse up over p1!");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 hover()
• The hover() method takes two functions and is a combination of the
mouseenter() and mouseleave() methods.
• The first function is executed when the mouse enters the HTML element,
and the second function is executed when the mouse leaves the HTML
element:
• Example: $("#p1").hover(function(){
alert("You hover p1!");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 focus()
• The focus() method attaches an event handler function to an HTML form
field.
• The function is executed when the form field gets focus:
• Example: $("input").focus(function(){
$(this).css("background-color", "#cccccc");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Commonly Used jQuery Event Methods
 blur()
• The blur() method attaches an event handler function to an HTML form
field.
• The function is executed when the form field loses focus:
• Example: $("input").blur(function(){
$(this).css("background-color", "#ffffff");
});
Custom Online Shop Developershttp://www.ifourtechnolab.com
Useful Event Functions
 .hide() display:true
 .show() display:none
 .toggle(func1, func2) first click calls func1, next click
executes func2
 .hover(over, out) mouseover, mouseout
Custom Online Shop Developershttp://www.ifourtechnolab.com
Effects
• show()
Shows the selected elements
• Hide()
Hides the selected elements
• fadeIn()
Fades in the selected elements
• fadeOut()
Fades out the selected elements
• fadeToggle()
Toggles between the fadeIn() and fadeOut() methods
• slideUp()
Slides-up (hides) the selected elements
Custom Online Shop Developershttp://www.ifourtechnolab.com
 slideDown()
Slides-down (shows) the selected elements
 Finish()
Stops, removes and completes all queued animations for the selected elements
 Delay()
Sets a delay for all queued functions on the selected elements
 Animate()
Runs a custom animation on the selected elements
 Stop()
Stops the currently running animation for the selected elements
 Dequeue()
Removes the next function from the queue, and then executes the function
Effects
Custom Online Shop Developershttp://www.ifourtechnolab.com
Thank you
Software development company indiahttp://www.ifourtechnolab.com

More Related Content

Viewers also liked

Organització política espanyola
Organització política espanyolaOrganització política espanyola
Organització política espanyolaciclesuperiorpm
 
[Estácio - IESAM] Automatizando Tarefas com Gulp.js
[Estácio - IESAM] Automatizando Tarefas com Gulp.js[Estácio - IESAM] Automatizando Tarefas com Gulp.js
[Estácio - IESAM] Automatizando Tarefas com Gulp.jsJoão Gabriel Lima
 
REST x SOAP : Qual abordagem escolher?
REST x SOAP : Qual abordagem escolher?REST x SOAP : Qual abordagem escolher?
REST x SOAP : Qual abordagem escolher?João Gabriel Lima
 
Disrupting Conventional Therapies with Digital Therapies
Disrupting Conventional Therapies with Digital TherapiesDisrupting Conventional Therapies with Digital Therapies
Disrupting Conventional Therapies with Digital TherapiesMedullan
 
IDS_Rapport plug-in for Salesforce_success story
IDS_Rapport plug-in for Salesforce_success storyIDS_Rapport plug-in for Salesforce_success story
IDS_Rapport plug-in for Salesforce_success storyMansa Systems
 
Lowering students' anxiety during information skills training with active lea...
Lowering students' anxiety during information skills training with active lea...Lowering students' anxiety during information skills training with active lea...
Lowering students' anxiety during information skills training with active lea...IL Group (CILIP Information Literacy Group)
 

Viewers also liked (8)

Organització política espanyola
Organització política espanyolaOrganització política espanyola
Organització política espanyola
 
[Estácio - IESAM] Automatizando Tarefas com Gulp.js
[Estácio - IESAM] Automatizando Tarefas com Gulp.js[Estácio - IESAM] Automatizando Tarefas com Gulp.js
[Estácio - IESAM] Automatizando Tarefas com Gulp.js
 
REST x SOAP : Qual abordagem escolher?
REST x SOAP : Qual abordagem escolher?REST x SOAP : Qual abordagem escolher?
REST x SOAP : Qual abordagem escolher?
 
Disrupting Conventional Therapies with Digital Therapies
Disrupting Conventional Therapies with Digital TherapiesDisrupting Conventional Therapies with Digital Therapies
Disrupting Conventional Therapies with Digital Therapies
 
IDS_Rapport plug-in for Salesforce_success story
IDS_Rapport plug-in for Salesforce_success storyIDS_Rapport plug-in for Salesforce_success story
IDS_Rapport plug-in for Salesforce_success story
 
Lowering students' anxiety during information skills training with active lea...
Lowering students' anxiety during information skills training with active lea...Lowering students' anxiety during information skills training with active lea...
Lowering students' anxiety during information skills training with active lea...
 
Fitxa islam2016
Fitxa islam2016Fitxa islam2016
Fitxa islam2016
 
L' islam
L' islamL' islam
L' islam
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Understanding JQuery for web development by software outsourcing company india

  • 2.  jQuery is a JavaScript Library.  jQuery greatly simplifies JavaScript programming.  jQuery is a lightweight, "write less, do more", JavaScript library.  jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.  The purpose of jQuery is to make it much easier to use JavaScript on your website. Introduction to JQuery Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 3.  There are lots of other JavaScript frameworks out there, but jQuery seems to be the most popular, and also the most extendable.  Many of the biggest companies on the Web use jQuery, such as: • Google • Microsoft • IBM • Netflix Advantages of jQuery Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 4.  There are several ways to start using jQuery on your web site. • 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 • Development version  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. How to Install Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 5. jQuery Syntax  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).  The Document Ready event is used to prevent any jQuery code from running before the document is finished loading (is ready).  It is good practice to wait for the document to be fully loaded and ready before working with it. Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 6. Enable jQuery in your page • jQuery can be enabled in your page by including reference to jQuery library file <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> • Introduce a jQuery function by using the below below given function. $(document).ready(function(){ //Script goes here }); OR $(function(){ //Script goes here }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 7. JavaScript vs jQuery • Example 1 - Hide an element with id "textbox“ //javascript document.getElementById('textbox').style.display = "none"; //jQuery $(' #textbox' ).hide(); • Example 2 - Create a <h1> tag with "my text“ //javascript var h1 = document.CreateElement("h1"); h1.innerHTML = "my text"; document.getElementsByTagName('body')[0].appendChild(h1); //jQuery $(' body').append( $("<h1/>").html("my text") ; Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 8.  jQuery selectors are one of the most important parts of the jQuery library.  jQuery selectors allow you to select and manipulate HTML element(s).  jQuery selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more.  The jQuery element selector selects elements based on the element name.  The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.  The jQuery class selector finds elements with a specific class. jQuery Selectors Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 9. Basic selectors • TagName document.getElementsByTagName("tagName"); (javascript) $("tagName") - $("div"), $("p"), $("div"),..... • Tag ID document.getElementById("id"); (javascript) $("#id") - $("#name"), $("#address") • Tag Class document.getElementsByClassName("className"); (javascript) $(".className") - $(".comment"), $(".code") • To select all elements - $("*") Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 10. Positional Selectors Syntax: Examples: $("selector:first") $("p:first") $("selector:last") $("p:last") $("selector:odd") $("p:odd") $("selector:even") $("p:even") $("selector:eq(i)") $("p:eq(1)") $("selector:gt(i)") $("p:gt(1)") $("selector:lt(i)") $("p:lt(1)") Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 11. Form Element(Custom) Selectors $("selector:visible") $("selector:input") $("selector:hidden") $("selector:text") $("selector:disabled") $("selector:password") $("selector:enabled") $("selector:radio") $("selector:checked") $("selector:checkbox") $("selector:selected") $("selector:submit") $("selector:header") $("selector:reset") $("selector:animated") $("selector:image") $("selector:not(selector:not)") $("selector:file") $("selector:button") Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 12. Retrieve, Set and Remove attribute Syntax: Examples: • $("selector").attr("name") • $("img").attr("src") • $("selector").attr("key","val") • $("p").attr("class","source") • $("selector").attr("key",fn()) • $("img").attr("height",calHt()) • $("selector").attr(properties) • $("img").attr({"src":"/path/","title" : "My Img"}); • $("selector").removeAttr(attr) • $("div").removeAttr("class“) Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 13. Class, HTML, Text, Value - Functions • $("selector").hasClass("className") • $("selector").addClass("className") • $("selector").removeClass("className") • $("selector").toggleClass("className") • $("selector").html() • $("selector").html("html code") • $("selector").text() • $("selector").text("text content") • $("selector").val() • $("selector").val("value") Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 14.  All the different visitor's actions that a web page can respond to are called events.  An event represents the precise moment when something happens.  Examples: • moving a mouse over an element • selecting a radio button • clicking on an element  The term "fires/fired" is often used with events. Example: "The keypress event is fired, the moment you press a key". Events Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 15. Commonly Used jQuery Event Methods  click() • The click() method attaches an event handler function to an HTML element. • The function is executed when the user clicks on the HTML element. • The following example says: When a click event fires on a <p> element; hide the current <p> element: • Example: $("p").click(function(){ $(this).hide(); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 16. Commonly Used jQuery Event Methods  dblclick() • The dblclick() method attaches an event handler function to an HTML element. • The function is executed when the user double-clicks on the HTML element: • Example: $("p").dblclick(function(){ $(this).hide(); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 17. Commonly Used jQuery Event Methods  mouseenter() • The mouseenter() method attaches an event handler function to an HTML element. • The function is executed when the mouse pointer enters the HTML element: • Example: $("#p1").mouseenter(function(){ alert("You entered p1!"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 18. Commonly Used jQuery Event Methods  mouseleave() • The mouseleave() method attaches an event handler function to an HTML element. • The function is executed when the mouse pointer leaves the HTML element: • Example: $("#p1").mouseleave(function(){ alert("Bye! You now leave p1!"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 19. Commonly Used jQuery Event Methods  mousedown() • The mousedown() method attaches an event handler function to an HTML element. • The function is executed, when the left, middle or right mouse button is pressed down, while the mouse is over the HTML element: • Example: $("#p1").mousedown(function(){ alert("Mouse down over p1!"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 20. Commonly Used jQuery Event Methods  mouseup() • The mouseup() method attaches an event handler function to an HTML element. • The function is executed, when the left, middle or right mouse button is released, while the mouse is over the HTML element: • Example: $("#p1").mouseup(function(){ alert("Mouse up over p1!"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 21. Commonly Used jQuery Event Methods  hover() • The hover() method takes two functions and is a combination of the mouseenter() and mouseleave() methods. • The first function is executed when the mouse enters the HTML element, and the second function is executed when the mouse leaves the HTML element: • Example: $("#p1").hover(function(){ alert("You hover p1!"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 22. Commonly Used jQuery Event Methods  focus() • The focus() method attaches an event handler function to an HTML form field. • The function is executed when the form field gets focus: • Example: $("input").focus(function(){ $(this).css("background-color", "#cccccc"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 23. Commonly Used jQuery Event Methods  blur() • The blur() method attaches an event handler function to an HTML form field. • The function is executed when the form field loses focus: • Example: $("input").blur(function(){ $(this).css("background-color", "#ffffff"); }); Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 24. Useful Event Functions  .hide() display:true  .show() display:none  .toggle(func1, func2) first click calls func1, next click executes func2  .hover(over, out) mouseover, mouseout Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 25. Effects • show() Shows the selected elements • Hide() Hides the selected elements • fadeIn() Fades in the selected elements • fadeOut() Fades out the selected elements • fadeToggle() Toggles between the fadeIn() and fadeOut() methods • slideUp() Slides-up (hides) the selected elements Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 26.  slideDown() Slides-down (shows) the selected elements  Finish() Stops, removes and completes all queued animations for the selected elements  Delay() Sets a delay for all queued functions on the selected elements  Animate() Runs a custom animation on the selected elements  Stop() Stops the currently running animation for the selected elements  Dequeue() Removes the next function from the queue, and then executes the function Effects Custom Online Shop Developershttp://www.ifourtechnolab.com
  • 27. Thank you Software development company indiahttp://www.ifourtechnolab.com

Editor's Notes

  1. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  2. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  3. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  4. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  5. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  6. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  7. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  8. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  9. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  10. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  11. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  12. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  13. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  14. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  15. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  16. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  17. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  18. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  19. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  20. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  21. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  22. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  23. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  24. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  25. Custom Online Shop Developers - http://www.ifourtechnolab.com/
  26. Software Outsourcing Company India - http://www.ifourtechnolab.com/