The hide() and show() methods in jQuery allow you to easily control the visibility of HTML elements with or without animation.
hide() removes an element from viewshow() brings a hidden element backBoth methods can be used with no parameters, a duration, or a duration with a callback function.
// Basic hide and show syntax
$("#element").hide();
$("#element").show();
// Instantly hide the element
$("#hideShowBox").hide();
// Instantly show the element
$("#hideShowBox").show();
You can control animation speed and execute logic after animation completes.
// Hide element with animation
$("#hideShowBox2").hide(1000);
// Show element with animation
$("#hideShowBox2").show(1000);
// Callback executes after hiding
$("#hideShowBox2").hide(1000,function(){
alert("Hidden!");
});
Adjust the slider to change the animation duration (ms) and use the Toggle button to switch visibility.