What is jQuery :
JQuery is a JavaScript library which is small, quick, with tons of features that makes things such as animation, event handling and manipulation in web browser easy to use and handle.
1-jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto -
2-Write less, do more.
3-jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery hasClass() Method
Determine whether any of the matched elements are assigned the given class
Syntax :
.hasClass(className)
The hasClass(class) method returns true if the specified class is present on at least one of the set of matched elements otherwise it returns false.
Now above exaple see hasClass() function matched element of result1 and result2 id and result 1 show not matched value result and result2 show matched result ,Return as true or false.
Imprtant Note :
The jQuery hasClass() method is used to check whether selected elements have specified class name or not. It returns TRUE if the specified class is present in any of the selected elements otherwise it returns FALSE.
jQuery Animations() Method
Perform a custom animation of a set of CSS properties.The jQuery animate() method is used to create custom animations.
Syntax :
$(selector).animate({params},speed,callback);
following information or paramter required ;
1-option speed paramater pass,
2-callback paramter is a function call when complete animation process.
Code :
now above example call animation method left to right direction,with specified speed parameter,
below simple example is call animation and passed parameter
:
animation start postion, defined opacity value, height and speed of animation if aniation is completed call function or above exmaple generate alert animation is completed.
jQuery fadeIn() Method
The .fadeIn() method animates the opacity of the matched elements.
Syntax :
selector.fadeIn(speed,[callback]);
Parameters
1-speed − A string representing one of the three predefined speeds :-
a-slow,
b-def,
c-fast
OR
the number of milliseconds to run the animation
2-callback − This is optional parameter representing a function to call once the animation is complete.
Code :
Simple example that fadeIn and fadeOut target element are hide and show using method.
:eq() Selector
Select the element at index n within the matched set.
The index-related selectors
a-:eq(),
b-:lt(),
c-:gt(),
d-:even,
e-:odd
filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set.
Code:
above html code and jquery code use eq method to check matched element of td element and apply color.
I hope that you like my code and you understand very well,if you like please share and comment.
JQuery is a JavaScript library which is small, quick, with tons of features that makes things such as animation, event handling and manipulation in web browser easy to use and handle.
1-jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto -
2-Write less, do more.
3-jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery hasClass() Method
Determine whether any of the matched elements are assigned the given class
Syntax :
.hasClass(className)
The hasClass(class) method returns true if the specified class is present on at least one of the set of matched elements otherwise it returns false.
Code :
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/query.min.js"></script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $("#result1").text( $("p#pid1").hasClass("red") ); $("#result2").text( $("p#pid2").hasClass("red") ); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "red" id = "pid1">Name : Disuza Jen.</p> <p class = "green" id = "pid2">Mobile : 123456789.</p> <div id = "result1"></div> <div id = "result2"></div> </body> </html>
Imprtant Note :
The jQuery hasClass() method is used to check whether selected elements have specified class name or not. It returns TRUE if the specified class is present in any of the selected elements otherwise it returns FALSE.
jQuery Animations() Method
Perform a custom animation of a set of CSS properties.The jQuery animate() method is used to create custom animations.
Syntax :
$(selector).animate({params},speed,callback);
following information or paramter required ;
1-option speed paramater pass,
2-callback paramter is a function call when complete animation process.
Code :
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ opacity: 0.25, left: "+=50", height: "toggle" },function() { alert('animation is completed.'); }); }); }); </script> </head> <body> <button>Start Animation</button> <p>Name: Disuza Jen</p> <p>Mobile: 1234567890</p> <div style="background:red;height:100px;width:100px;position:absolute;"></div> </body> </html>
below simple example is call animation and passed parameter
:
$( "#clickme" ).click(function() { $( "#book" ).animate({ opacity: 0.25, left: "+=50", height: "toggle" }, 5000, function() { // Animation complete. }); });
jQuery fadeIn() Method
The .fadeIn() method animates the opacity of the matched elements.
Syntax :
selector.fadeIn(speed,[callback]);
Parameters
1-speed − A string representing one of the three predefined speeds :-
a-slow,
b-def,
c-fast
OR
the number of milliseconds to run the animation
2-callback − This is optional parameter representing a function to call once the animation is complete.
Code :
<html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $("#in").click(function(){ $(".target").fadeIn( 'slow', function(){ $(".log").text('Fade In Complete'); }); }); $("#out").click(function(){ $(".target").fadeOut( 'slow', function(){ $(".log").text('Fade Out Complete'); }); }); }); </script> </head> <body> <h1>Free Teachnology Blogspot</h1> <p>Name: Disuza Jen</p> <p>Mobile: 1234567890</p> <p>fadeIn and fadeOut example of show hide and unhide element of particular element.</p> <button id = "out"> Fade Out </button> <button id = "in"> Fade In</button> <div class = "target"> <p>Name: Disuza Jen</p> <p>Mobile: 1234567890</p> </div> <div class = "log"></div> </body> </html>
:eq() Selector
Select the element at index n within the matched set.
The index-related selectors
a-:eq(),
b-:lt(),
c-:gt(),
d-:even,
e-:odd
filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set.
Code:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>eq demo</title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <h1>Free Teachnology Blogspot</h1> <p>Name: Disuza Jen</p> <p>Mobile: 1234567890</p> <table border="1"> <tr> <td>Test 1</td> <td>Test 2</td> <td>Test 3</td> </tr> <tr> <td>Test 4</td> <td>Test 5</td> <td>Test 6</td> </tr> <tr> <td>Test 7</td> <td>Test 8</td> <td>Test 9</td> </tr> </table> <script> $("td:eq(2)").css("color","red"); $("td:eq(4)").css("color","green"); $("td:eq(7)").css("color","blue"); </script> </body> </html>
I hope that you like my code and you understand very well,if you like please share and comment.
Comments