jQuery Tutorial
hide method is used to hide or invisible the selected elements in the web page.
jquery hide syntax
$(selector).hide(speed of animation, easing, callback function)
In jQuery all the three parameters are optional for hide method.
"fast" - hides the element faster.
"normal" - hides the element in normal.
"slow" - hides the element slower.
milliseconds - hides the element animation as based on specified milliseconds.
"swing" - In middle of the animation is faster but slower in beginning and end of animation.
"linear" - Animation is consistent from beginning to end.
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>jQuery hide method</title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#btnHide').click(function () { $("div").hide(); }); }); </script> </head> <body> <input type="button" id="btnHide" value="Hide"/> <div style="height:200px;width:200px;background-color:blue;color:white;"> This div will be hidden! </div> </body> </html>Output:
Shows div element
Hides div after clicking on hide button
call back function is used to update the hidden div text when shows on clicking of hide button.
$(document).ready(function () { $('#btnHide').click(function () { $("div").hide(function () { alert('call back function!'); }); }); });
jquery hide function is used to hide the div element with slow animation .
$(document).ready(function () { $('#btnHide').click(function () { $("div").hide("slow"); }); });
jquery hide function is used to hide the element with animation slower for 15000 milliseconds.
$(document).ready(function () { $('#btnHide').click(function () { $("div").hide(15000); }); });
jquery hide function is used to hide the element with animation slower for 15000 milliseconds with consistent speed.
$(document).ready(function () { $('#btnHide').click(function () { $("div").hide("normal", "linear"); }); });
css method is also used to hide the element.
$(document).ready(function () { $('#btnHide').click(function () { $("div").css("display", "none"); }); });« Previous Next »
jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page