SlideShare a Scribd company logo
JQUERY
MUHAMMAD EHTISHAM SIDDIQUI
APTECH COMPUTER EDUCATION
TOPICS TO BE COVERED
Introduction to JQuery.
Purpose of JQuery.
How to use Jquery.
Syntax of using JQuery.
Functions and Events of JQuery.
Selectors and functions of JQuery.
Example of JQuery.
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.
• Many of the biggest companies on the Web use jQuery, such as:
• Google
• Microsoft
• IBM
• Netflix
WHAT IS JQUERY?
PURPOSE OF JQUERY
The purpose of jQuery is to make it much easier to use JavaScript
on your website.
We can take advantages of JavaScript for:-
• It helps to improve the performance of the application
• It helps to develop most browser compatible web page
• It helps to implement UI related critical functionality without writing
hundreds of lines of codes
• It is fast
• It is extensible – jQuery can be extended to implement customized
behavior
HOW TO USE JQUERY?
There are two ways to use JQuery.
Download JQuery file from http://jquery.com/download/
And link JQuery file in your HTML page.
<head>
<script src="jquery-3.3.1.min.js"></script>
</head>
Use online JQuery file CDN(Content Delivery Network)
<script type="text/javascript" language="Javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
</script>
HOW TO USE JQUERY?
IF CDN Doesn’t support you can use your local file.
<script type="text/javascript" language="Javascript"
src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"></script>
<script type='text/javascript'>//<![CDATA[
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript
src='/Script/jquery-1.4.1.min.js' type='text/javascript' %3E%3C/script%3E"));
}//]]>
</script>
SYNTAX OF JQUERY
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)
Syntax:-
$(document).action(function(){
// jQuery methods go here...
});
SELECTING ELEMENTS IN JQUERY
SELECTING ELEMENTS IN JQUERY(CSS SELECTORS)
SELECTING ELEMENTS IN JQUERY(CUSTOM SELECTORS)
EXAMPLE OF SELECTORS
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(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 to hide paragraphs</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#test").hide();
}); });
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p id="test">This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
EXAMPLE OF SELECTORS(CSS SELECTORS)
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>animated demo</title> <style>
div {
background: yellow;
border: 1px solid #AAA;
width: 80px;
height: 80px;margin: 0 5px;float: left;}
div.colored {background: green;}</style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body>
<button id="run">Run</button>
<div></div>
<div id="mover"></div><div></div><script> $( "#run" ).click(function() { $( "div:animated" ).toggleClass( "colored" );});function animateIt() {
$( "#mover" ).slideToggle( "slow", animateIt );}
animateIt();
</script>
</body>
</html>
CSS CLASS NAME
CSS STYLES
EXAMPLE OF CSS STYLES USING JQUERY
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").focus(function(){
$(this).css("background-color", "#cccccc");
});
$("input").blur(function(){
$(this).css("background-color", "#ffffff");
});
});
</script>
</head>
<body>
Name: <input type="text" name="fullname"><br>
Email: <input type="text" name="email">
</body>
</html>
EXAMPLE OF CSS STYLES USING JQUERY
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").on({
mouseenter: function(){
$(this).css("background-color", "lightgray");
},
mouseleave: function(){
$(this).css("background-color", "lightblue"); },
click: function(){
$(this).css("background-color", "yellow");
} });});
</script>
</head>
<body>
<p>Click or move the mouse pointer over this paragraph.</p>
</body>
</html>
EXAMPLE OF CSS STYLES USING JQUERY
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").on({
mouseenter: function(){
$(this).css("background-color", "lightgray");
},
mouseleave: function(){
$(this).css("background-color", "lightblue"); },
click: function(){
$(this).css("background-color", "yellow");
} });});
</script>
</head>
<body>
<p>Click or move the mouse pointer over this paragraph.</p>
</body>
</html>
JQUERY EVENTS
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
JQUERY EVENTS
Mouse Events Keyboard Events Form Events Document/Window
Events
click keypress submit load
dblclick keydown change resize
mouseenter keyup focus scroll
mouseleave blur unload
JQUERY EVENTS
Mouse Events Keyboard Events Form Events Document/Window
Events
click keypress submit load
dblclick keydown change resize
mouseenter keyup focus scroll
mouseleave blur unload
JQUERY EVENTS(MOUSE) -> CLICK
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
JQUERY EVENTS(MOUSE) -> DBL CLICK
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").dblclick(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you double-click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>
JQUERY EVENTS(MOUSE) -> MOUSE ENTER
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#p1").mouseenter(function(){
alert("You entered p1!");
});
});
</script>
</head>
<body>
<p id="p1">Enter this paragraph.</p>
</body>
</html>
JQUERY EVENTS(MOUSE) -> HOVER
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#p1").hover(function(){
alert("You entered p1!");
}, function(){
alert("Bye! You now leave p1!");
});
});
</script>
</head>
<body>
<p id="p1">This is a paragraph.</p>
</body>
</html>
JQUERY EVENTS(MOUSE) -> BLUR
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#p1").hover(function(){
alert("You entered p1!");
},
function(){
alert("Bye! You now leave p1!");
});
});
</script>
</head>
<body>
<p id="p1">This is a paragraph.</p>
</body>
</html>
HIDE/SHOW
<!DOCTYPE html>
<html><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
HIDE WITH SPEED
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide(1000);
});
});
</script>
</head>
<body>
<button>Hide</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>
TOGGLE
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").hover(function(){
$("p").toggle(1000);
});
});
</script>
</head>
<body>
<button>Toggle between hiding and showing the paragraphs</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>
TOGGLE
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").hover(function(){
$("p").toggle(1000);
});
});
</script>
</head>
<body>
<button>Toggle between hiding and showing the paragraphs</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>
FADEIN()
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000) ; }); });
</script>
</head>
<body>
<p>Demonstrate fadeIn() with different parameters.</p>
<button>Click to fade in boxes</button><br><br>
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body></html>
FADEOUT()
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeOut();
$("#div2").fadeOut("slow");
$("#div3").fadeOut(3000);
}); });
</script></head>
<body>
<p>Demonstrate fadeOut() with different parameters.</p>
<button>Click to fade out boxes</button><br><br>
<div id="div1" style="width:80px;height:80px;background-color:red;"></div><br>
<div id="div2" style="width:80px;height:80px;background-color:green;"></div><br>
<div id="div3" style="width:80px;height:80px;background-color:blue;"></div></body></html>
FADEIN() & FADEOUT()
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeToggle();
$("#div2").fadeToggle("slow");
$("#div3").fadeToggle(3000);
}); });
</script>
</head><body>
<p>Demonstrate fadeToggle() with different speed parameters.</p>
<button>Click to fade in/out boxes</button><br><br>
<div id="div1" style="width:80px;height:80px;background-color:red;"></div><br>
<div id="div2" style="width:80px;height:80px;background-color:green;"></div><br>
<div id="div3" style="width:80px;height:80px;background-color:blue;"></div></body></html>
SLIDE
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow"); }); }); </script> <style>
#panel, #flip {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3; }#panel {
padding: 50px;
display: none;}</style></head><body>
<div id="flip">Click to slide the panel down or up</div>
<div id="panel">Hello world!</div>
</body>
</html>
ANIMATION
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({
left: '250px',
height: '+=150px',
width: '+=150px'
}); }); });</script> </head><body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of
the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
</body>
</html>
ANIMATION
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({
height: 'toggle' }); }); });
</script>
</head>
<body>
<p>Click the button multiple times to toggle the animation.</p>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of
the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
</body>
</html>
J Query (Complete Course) by Muhammad Ehtisham Siddiqui

More Related Content

PPTX
Jquery Complete Presentation along with Javascript Basics
PDF
jQuery Mobile: Progressive Enhancement with HTML5
PDF
jQuery for beginners
PDF
SwiftUI and Combine All the Things
PDF
jQuery: Nuts, Bolts and Bling
PDF
Fundamental JQuery
PDF
Javascript MVC & Backbone Tips & Tricks
PDF
MVVM with SwiftUI and Combine
Jquery Complete Presentation along with Javascript Basics
jQuery Mobile: Progressive Enhancement with HTML5
jQuery for beginners
SwiftUI and Combine All the Things
jQuery: Nuts, Bolts and Bling
Fundamental JQuery
Javascript MVC & Backbone Tips & Tricks
MVVM with SwiftUI and Combine

What's hot (20)

PPTX
SharePoint and jQuery Essentials
PPTX
Introduction to jQuery Mobile
PPTX
jQuery Mobile Introduction ( demo on EZoapp )
KEY
jQuery('#knowledge').appendTo('#you');
PPTX
jQuery besic
PDF
jQuery Loves Developers - Oredev 2009
PDF
jQuery in the [Aol.] Enterprise
PPTX
Unobtrusive javascript with jQuery
PPTX
Client Web
PDF
jQuery Essentials
PPTX
jQuery Presentation
PDF
jQuery Introduction
PPTX
Migration to jQuery 3.5.x
PPTX
Getting the Most Out of jQuery Widgets
PDF
jQuery Features to Avoid
PDF
The Art of AngularJS in 2015 - Angular Summit 2015
PDF
Introduction to jQuery
PDF
Stack Overflow Austin - jQuery for Developers
PDF
Overview on jQuery mobile
PPT
SharePoint and jQuery Essentials
Introduction to jQuery Mobile
jQuery Mobile Introduction ( demo on EZoapp )
jQuery('#knowledge').appendTo('#you');
jQuery besic
jQuery Loves Developers - Oredev 2009
jQuery in the [Aol.] Enterprise
Unobtrusive javascript with jQuery
Client Web
jQuery Essentials
jQuery Presentation
jQuery Introduction
Migration to jQuery 3.5.x
Getting the Most Out of jQuery Widgets
jQuery Features to Avoid
The Art of AngularJS in 2015 - Angular Summit 2015
Introduction to jQuery
Stack Overflow Austin - jQuery for Developers
Overview on jQuery mobile
Ad

Similar to J Query (Complete Course) by Muhammad Ehtisham Siddiqui (20)

PPTX
Introduction to jQuery
PPTX
PDF
Short intro to JQuery and Modernizr
PPTX
Unit3.pptx
PDF
Advanced JQuery Mobile tutorial with Phonegap
PPTX
PPTX
PPTX
jQuery for web development
PPTX
JQuery_and_Ajax.pptx
PPT
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
PPTX
JavaScript and jQuery Basics
PPTX
lec 14-15 Jquery_All About J-query_.pptx
PPSX
JQuery Comprehensive Overview
PPTX
Jquery Basics
PPTX
A Rich Web Experience with jQuery, Ajax and .NET
Introduction to jQuery
Short intro to JQuery and Modernizr
Unit3.pptx
Advanced JQuery Mobile tutorial with Phonegap
jQuery for web development
JQuery_and_Ajax.pptx
Jquery PPT_Finalfgfgdfgdr5tryeujkhdwappt
JavaScript and jQuery Basics
lec 14-15 Jquery_All About J-query_.pptx
JQuery Comprehensive Overview
Jquery Basics
A Rich Web Experience with jQuery, Ajax and .NET
Ad

More from Muhammad Ehtisham Siddiqui (20)

PPTX
C programming Tutorial Session 4
PPTX
C programming Tutorial Session 4
PPTX
C programming Tutorial Session 3
PPTX
C programming Tutorial Session 2
PPTX
C programming Tutorial Session 1
PPTX
HTML5 Web storage
PPTX
JavaScript Session 2
PPTX
JavaScript Session 3
PPTX
Javascript session 1
PPTX
Html audio video
PPTX
Html 5 geolocation api
PPTX
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
PPTX
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
PPTX
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
PPTX
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
PPTX
Building Next Generation Websites Session6
PPTX
Building Next Generation Websites Session5
PPTX
Building Next Generation Websites Session4
PPTX
Office session14
C programming Tutorial Session 4
C programming Tutorial Session 4
C programming Tutorial Session 3
C programming Tutorial Session 2
C programming Tutorial Session 1
HTML5 Web storage
JavaScript Session 2
JavaScript Session 3
Javascript session 1
Html audio video
Html 5 geolocation api
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session6
Building Next Generation Websites Session5
Building Next Generation Websites Session4
Office session14

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Pre independence Education in Inndia.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
01-Introduction-to-Information-Management.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Cell Types and Its function , kingdom of life
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
O7-L3 Supply Chain Operations - ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
RMMM.pdf make it easy to upload and study
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pre independence Education in Inndia.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
01-Introduction-to-Information-Management.pdf
Microbial disease of the cardiovascular and lymphatic systems
Cell Types and Its function , kingdom of life
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis

J Query (Complete Course) by Muhammad Ehtisham Siddiqui

  • 2. TOPICS TO BE COVERED Introduction to JQuery. Purpose of JQuery. How to use Jquery. Syntax of using JQuery. Functions and Events of JQuery. Selectors and functions of JQuery. Example of JQuery.
  • 3. 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. • Many of the biggest companies on the Web use jQuery, such as: • Google • Microsoft • IBM • Netflix
  • 5. PURPOSE OF JQUERY The purpose of jQuery is to make it much easier to use JavaScript on your website. We can take advantages of JavaScript for:- • It helps to improve the performance of the application • It helps to develop most browser compatible web page • It helps to implement UI related critical functionality without writing hundreds of lines of codes • It is fast • It is extensible – jQuery can be extended to implement customized behavior
  • 6. HOW TO USE JQUERY? There are two ways to use JQuery. Download JQuery file from http://jquery.com/download/ And link JQuery file in your HTML page. <head> <script src="jquery-3.3.1.min.js"></script> </head> Use online JQuery file CDN(Content Delivery Network) <script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"> </script>
  • 7. HOW TO USE JQUERY? IF CDN Doesn’t support you can use your local file. <script type="text/javascript" language="Javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"></script> <script type='text/javascript'>//<![CDATA[ if (typeof jQuery == 'undefined') { document.write(unescape("%3Cscript src='/Script/jquery-1.4.1.min.js' type='text/javascript' %3E%3C/script%3E")); }//]]> </script>
  • 8. SYNTAX OF JQUERY 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) Syntax:- $(document).action(function(){ // jQuery methods go here... });
  • 10. SELECTING ELEMENTS IN JQUERY(CSS SELECTORS)
  • 11. SELECTING ELEMENTS IN JQUERY(CUSTOM SELECTORS)
  • 12. EXAMPLE OF SELECTORS <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(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 to hide paragraphs</button> </body> </html> <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#test").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p id="test">This is another paragraph.</p> <button>Click me</button> </body> </html>
  • 13. EXAMPLE OF SELECTORS(CSS SELECTORS) <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>animated demo</title> <style> div { background: yellow; border: 1px solid #AAA; width: 80px; height: 80px;margin: 0 5px;float: left;} div.colored {background: green;}</style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body> <button id="run">Run</button> <div></div> <div id="mover"></div><div></div><script> $( "#run" ).click(function() { $( "div:animated" ).toggleClass( "colored" );});function animateIt() { $( "#mover" ).slideToggle( "slow", animateIt );} animateIt(); </script> </body> </html>
  • 16. EXAMPLE OF CSS STYLES USING JQUERY <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").focus(function(){ $(this).css("background-color", "#cccccc"); }); $("input").blur(function(){ $(this).css("background-color", "#ffffff"); }); }); </script> </head> <body> Name: <input type="text" name="fullname"><br> Email: <input type="text" name="email"> </body> </html>
  • 17. EXAMPLE OF CSS STYLES USING JQUERY <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on({ mouseenter: function(){ $(this).css("background-color", "lightgray"); }, mouseleave: function(){ $(this).css("background-color", "lightblue"); }, click: function(){ $(this).css("background-color", "yellow"); } });}); </script> </head> <body> <p>Click or move the mouse pointer over this paragraph.</p> </body> </html>
  • 18. EXAMPLE OF CSS STYLES USING JQUERY <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on({ mouseenter: function(){ $(this).css("background-color", "lightgray"); }, mouseleave: function(){ $(this).css("background-color", "lightblue"); }, click: function(){ $(this).css("background-color", "yellow"); } });}); </script> </head> <body> <p>Click or move the mouse pointer over this paragraph.</p> </body> </html>
  • 19. JQUERY EVENTS 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
  • 20. JQUERY EVENTS Mouse Events Keyboard Events Form Events Document/Window Events click keypress submit load dblclick keydown change resize mouseenter keyup focus scroll mouseleave blur unload
  • 21. JQUERY EVENTS Mouse Events Keyboard Events Form Events Document/Window Events click keypress submit load dblclick keydown change resize mouseenter keyup focus scroll mouseleave blur unload
  • 22. JQUERY EVENTS(MOUSE) -> CLICK <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you click on me, I will disappear.</p> <p>Click me away!</p> <p>Click me too!</p> </body>
  • 23. JQUERY EVENTS(MOUSE) -> DBL CLICK <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").dblclick(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you double-click on me, I will disappear.</p> <p>Click me away!</p> <p>Click me too!</p> </body> </html>
  • 24. JQUERY EVENTS(MOUSE) -> MOUSE ENTER <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#p1").mouseenter(function(){ alert("You entered p1!"); }); }); </script> </head> <body> <p id="p1">Enter this paragraph.</p> </body> </html>
  • 25. JQUERY EVENTS(MOUSE) -> HOVER <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#p1").hover(function(){ alert("You entered p1!"); }, function(){ alert("Bye! You now leave p1!"); }); }); </script> </head> <body> <p id="p1">This is a paragraph.</p> </body> </html>
  • 26. JQUERY EVENTS(MOUSE) -> BLUR <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#p1").hover(function(){ alert("You entered p1!"); }, function(){ alert("Bye! You now leave p1!"); }); }); </script> </head> <body> <p id="p1">This is a paragraph.</p> </body> </html>
  • 28. HIDE WITH SPEED <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); }); }); </script> </head> <body> <button>Hide</button> <p>This is a paragraph with little content.</p> <p>This is another small paragraph.</p> </body> </html>
  • 31. FADEIN() <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeIn(); $("#div2").fadeIn("slow"); $("#div3").fadeIn(3000) ; }); }); </script> </head> <body> <p>Demonstrate fadeIn() with different parameters.</p> <button>Click to fade in boxes</button><br><br> <div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br> <div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br> <div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div> </body></html>
  • 32. FADEOUT() <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeOut(); $("#div2").fadeOut("slow"); $("#div3").fadeOut(3000); }); }); </script></head> <body> <p>Demonstrate fadeOut() with different parameters.</p> <button>Click to fade out boxes</button><br><br> <div id="div1" style="width:80px;height:80px;background-color:red;"></div><br> <div id="div2" style="width:80px;height:80px;background-color:green;"></div><br> <div id="div3" style="width:80px;height:80px;background-color:blue;"></div></body></html>
  • 33. FADEIN() & FADEOUT() <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeToggle(); $("#div2").fadeToggle("slow"); $("#div3").fadeToggle(3000); }); }); </script> </head><body> <p>Demonstrate fadeToggle() with different speed parameters.</p> <button>Click to fade in/out boxes</button><br><br> <div id="div1" style="width:80px;height:80px;background-color:red;"></div><br> <div id="div2" style="width:80px;height:80px;background-color:green;"></div><br> <div id="div3" style="width:80px;height:80px;background-color:blue;"></div></body></html>
  • 34. SLIDE <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#flip").click(function(){ $("#panel").slideToggle("slow"); }); }); </script> <style> #panel, #flip { padding: 5px; text-align: center; background-color: #e5eecc; border: solid 1px #c3c3c3; }#panel { padding: 50px; display: none;}</style></head><body> <div id="flip">Click to slide the panel down or up</div> <div id="panel">Hello world!</div> </body> </html>
  • 35. ANIMATION <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ left: '250px', height: '+=150px', width: '+=150px' }); }); });</script> </head><body> <button>Start Animation</button> <p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div> </body> </html>
  • 36. ANIMATION <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ height: 'toggle' }); }); }); </script> </head> <body> <p>Click the button multiple times to toggle the animation.</p> <button>Start Animation</button> <p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div> </body> </html>