Categories: Programming

Commonly Used jQuery Methods

In this introduction we will learn how to use hide and show method in JQuery with some Commonly Used jQuery Methods.

JQuery Hide() and Show() Method:

INTRODUCTION:

In JQuery , if you have to hide or show an element corresponding to any event in html element then JQuery provides you a pre-defined method called hide and show method.

SYNTAX:

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

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

USAGE:

This hide() method instantly hide any HTML element and if you want to show the hidden element then you have to call the show method. This hide() and show() method takes two optional parameters speed and a callback function.

PARAMETERS:

Hide() and Show() method takes two optional parameters – Speed & Callback.

Speed parameter can take 3 values i.e ”fast”, ”slow”, milliseconds

  • ”fast” value performs the hiding and showing animation extremely fast
  • ”slow” value performs the hiding and showing animation slow and smoothly
  • You can put custom animation time in milliseconds to make the animation smoother

Lastly if you want any task to be performed after the hide() and show() then you have to use the callback function.

JQuery Toggle() Method:

In JQuery, if you want to perform the hide() and show() method simultaneously then you have a built-in method called Toggle().

SYNTAX:

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

USAGE:

Toggle() method hides the element if it is shown and shows the element if it is hidden.

PARAMETERS:

The parameters toggle() method are similar to previously discussed hide() and how() method.

In this output , if you click on hide button the div element will be hidden.

And now if show button is pressed the div will be shown again.

If you click on the “Hide” button, The entire div will disappear.

Recent Posts

Laying Porcelain Stoneware On The Floor

Today, several basic floor finishes are used. As a rule, these are self-leveling floors, characterized…

5 days ago

Exploring the World’s Oldest Civilizations and Their Landmarks

When discussing humanity’s past, it is integral to contemplate the origin of life. In the…

6 days ago

Why is Node.js Top Programming Language in ERP Development?

Node.js is a JavaScript runtime based on Chrome's V8 JavaScript engine, and it's widely praised…

1 week ago

The Mental Health Benefits of Keeping Your House Clean

A clean and organized living space brings physical advantages and contributes significantly to our mental…

1 week ago

Tackling the Challenges of GDPR in the age of Big Data

Protecting private data has become paramount in the digital era where Big Data is king.…

1 week ago

The First 90 Days: Essential Steps for a Successful Post-University Job Search

University can be the most fulfilling time of your life, as you achieve the qualifications…

2 weeks ago