Fancy and Animated Hide and Show of Paragraph Tag using jQuery


Preface


This post shows how to create a Fancy and Animated Hide and Show of Paragraph Tag in ASP.NET using jQuery. Please assume this post as addition to my last post titled "Animated Hide and Show of Paragraph Tag using jQuery". If you review my last post, you will notice that I have used two different <a> tags that is <a href="#" class="show"> and <a href="#" class="hide">, and by using jQuery .hide() and .show() methods I switched both one by one. But it is not the right way, if jQuery has compound effects. If we use Compound Effects, only a single <a> tag will do all this, even rest coding will become short and quick.

Setup Demonstration Page

Let's setup the demonstration page, find the code below:


Steup jQuery Methods

Let's setup the jQuery methods, find the code below:


This toggling can be achieved by first checking the visibility of the matched elements and then calling the appropriate method. Using an if/else statement is a perfectly reasonable way to toggle elements' visibility. However, with jQuery's compound effects we can remove some conditional logic from our code. jQuery provides a .toggle() method, which acts like .show() and .hide(), and like them, can be used with a speed argument or without. Code will be something like

$P1.slideToggle('slow');

Here is the new code snippets that is using .toggle() method:


Find my running screen below.


I hope you like it.

Comments

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples