How to use jQuery toggle() method

Avatar
M

Maksudur Rahman

Software Engineer

8071Views
5mRead
0Reactions

By using jQuery, You can toggle between hiding and showing HTML elements with the toggle() method.

Shown elements are hidden and hidden elements are shown:

Syntax:

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

Example:

$("#show-hide").click(function(){
  $("p").toggle();
});

 

Recommended Resources & Courses

React to this article