Skip to content
the poor coder

jquery visibility effects

Poor Man
Published
Reading time
1 min read
On this page

jQuery Visibility Effects#

jQuery is a popular JavaScript library that simplifies the process of manipulating HTML documents. One of its useful features is the ability to control the visibility of HTML elements through animation effects. Here are some common methods to achieve this:

fadeIn() and fadeOut() methods#

The fadeIn() and fadeOut() methods are used to gradually show or hide an element. They take an optional parameter for the duration of the animation in milliseconds, and an optional parameter for a callback function to be executed after the animation completes. Here's an example:

Text

$(document).ready(function(){
    $("button").click(function(){
        $("p").fadeOut(1000);
    });
});

In this example, a button is selected using the $() function, and when it is clicked, the <p> element is faded out over a 1-second period.

slideDown() and slideUp() methods#

The slideDown() and slideUp() methods are used to show or hide an element by sliding it up or down. They also take optional parameters for duration and callback functions. Here's an example:

Text

$(document).ready(function(){
    $("button").click(function(){
        $("p").slideUp(1000);
    });
});

This example selects a button and when it is clicked, the <p> element slides up over a 1-second period.

show() and hide() methods#

The show() and hide() methods simply show or hide an element, without any animation effect. They also take optional parameters for duration and callback functions. Here's an example:

Text

$(document).ready(function(){
    $("button").click(function(){
        $("p").hide(1000);
    });
});

In this example, a button is selected and when it is clicked, the <p> element is hidden over a 1-second period.

Overall, these methods are useful for creating dynamic and interactive effects on web pages using jQuery.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC