jquery fadeOut() method
Translation results:
fadeout
UK ['feɪd'aʊt] US ['feɪd'aʊt]
n. Fade out, fade out
jquery fadeOut() methodsyntax
Function: fadeOut() method uses the fadeout effect to hide the selected element, if the element is hidden.
Syntax: $(selector).fadeOut(speed,callback)
Parameters:
Parameters | Description |
speed | Optional. Specifies how quickly an element goes from visible to hidden. Default is "normal". Possible values: milliseconds (e.g. 1500) "slow" "normal" "fast" When setting the speed, the element will gradually change its transparency as it goes from visible to hidden (this will create a fade-out effect). |
callback | Optional. The function to be executed after the fadeOut function is executed. To learn more about callbacks, visit our jQuery Callback chapter. This parameter cannot be set unless the speed parameter is set. |
Note: If the element has been hidden, the effect will not change unless a callback function is specified.
jquery fadeOut() methodexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("p").fadeOut() }); $(".btn2").click(function(){ $("p").fadeIn(); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button class="btn1">Hide</button> <button class="btn2">Show</button> </body> </html>
Click the "Run instance" button to view the online instance