jQuery Hide And Show

jQuery hide effects are used to set the display: none inline property & jQuery show effects are used to remove the inline style of the selected element.

Every HTML element has a display property like block, inline, or inline-block.

jQuery hide method uses CSS inline style and simply sets the display:none property of the selected element.

jQuery show method is used to restore the display property of selected elements means it removed the CSS inline style property display: none of the selected elements and restores the previously predefined display property like block, inline, or inline-block.

Source Code

          
            $(selector).hide();
$(selector).show();          
        
Try it now

Please keep in mind that parameter speed indicates hide and show animation speed. It takes 'slow', 'fast' or milliseconds.

The optional callback parameter is a function and it will be executed whenever the jquery hide and show method is completed.

Jquery Show And Hide Method Parameter

Jquery show and hide method takes either string value like 'slow', 'fast', or integer value that indicates time. You can also specify a callback function that is executed whenever the hide and show method is completed. Please keep in mind that the string 'slow' indicates 600 milliseconds while the string 'fast' indicates 200 milliseconds.

Source Code

          
            $(selector).hide(speed);
$(selector).show(speed);          
        
Try it now

jQuery Hide And Show Method Optional Parameter(callback function)

jQuery hide and show method optional parameter that id callback function will be executed after the completion of hide and show method.

Source Code

          
            $(selector).hide(speed,callback);
$(selector).show(speed,callback);          
        
Try it now

Jquery Toggle

Jquery toggle(speed, callback) method is used to show the hidden element or to hide the shown element.

Please keep in mind that speed and callback function both are optional. The speed parameter can take the following string values: "slow", "fast", or milliseconds.

The optional parameter callback function will be executed whenever toggle() method has been completed.

Source Code

          
            $(selector).toggle(speed,callback);          
        
Try it now

Web Tutorials

jQuery Hide And Show
Html Tutorial HTML
Javascript Tutorial JAVASCRIPT
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4