jQuery
HTML
CSS
JavaScript
PHP
SQL
WordPress
jQuery Tutorials

Overview

jQuery can be used to hide, show, fade in/out, or slide up/down HTML elements on the page, creating effects and animations with a great deal of control.

The following are some quick examples of the methods used to create effects. A complete list of effects can be found here along with more detailed descriptions of their intended use and syntax.

animate() Method

The animate() method performs a custom animation on an HTML element, changing one CSS property value to another gradually, creating an animated effect.

				
					// animate the opacity of the element to 0.2, slowly, using "swing" easing
$('button').click(function() {
    $('div').animate({opacity: '0.2'}, 'slow', 'swing');
});
				
			

fadeIn() Method

The fadeIn() method gradually changes, fades in, the opacity for the selected element from completely hidden to completely visible. The visible item will now take up space on the page, affecting the layout.

				
					// fade element in over 2000ms using "swing" easing
$('button').click(function() {
    $('div').fadeIn(2000, 'swing');
});
				
			

fadeOut() Method

The fadeOut() method gradually changes, fades out, the opacity for the selected element from completely visible to completely hidden. The hidden item will no longer take up space on the page, affecting the layout.

				
					// fade element out over 2000ms using "swing" easing
$('button').click(function() {
    $('div').fadeOut(2000, 'swing');
});
				
			

hide() Method

The hide() method hides the selected element. The hidden item will no longer take up space on the page, affecting the layout.

				
					// hide the element over 2000ms using "swing" easing
$('button').click(function() {
    $('div').hide(2000, 'swing');
});
				
			

show() Method

The show() method shows the selected hidden element. The shown item will now take up space on the page, affecting the layout. It works on elements hidden with jQuery methods and those with display: none in CSS.

				
					// show the element over 2000ms using "swing" easing
$('button').click(function() {
    $('div').show(2000, 'swing');
});
				
			

slideDown() Method

The slideDown() method slides down and shows the selected element. The visible item will now take up space on the page, affecting the layout. It works on elements hidden with jQuery methods and those with display: none in CSS.

				
					// slide the element down over 2000ms using "swing" easing
$('button').click(function() {
    $('div').slideDown(2000, 'swing');
});
				
			

slideUp() Method

The slideUp() method slides up and hides the selected element. The hidden item will no longer take up space on the page, affecting the layout.

				
					// slide the element up over 2000ms using "swing" easing
$('button').click(function() {
    $('div').slideUp(2000, 'swing');
});
				
			

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

jQuery
HTML
CSS
JavaScript
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.