jQuery Effects - Hide and Show


jQuery hide() and show()

You can use jQuery to make parts of a webpage disappear or reappear using the "hide()" and "show()" methods.

Syntax:

$(selector).hide(speed,callback);

$(selector).show(speed,callback);

You can use the "speed" option to control how quickly something appears or disappears. You can choose from three options: "slow," "fast," or you can specify the time in milliseconds.

The optional callback parameter is a function that runs once the hide() or show() method finishes its work. We'll explain callback functions more in a later part.

Here's an example that shows how the 'speed' parameter works with the hide() function:


jQuery toggle()

You can easily switch between making something disappear or appear using the toggle() method.

Visible elements become invisible, and invisible elements become visible:

Syntax:

$(selector).toggle(speed,callback);

You can choose how fast something happens using the "speed" option. You can set it to "slow," "fast," or a specific number of milliseconds.

The "optional callback parameter" is a function that runs once the toggle() action is finished.