JQuery UI Switchclass Effects Animation Tutorial




JQuery UI Switchclass Effects Animation Tutorial

Hi Guys,

In this example,I will learn you how to use switch class effects animation in jquery ui.you can easy use switch class efffects in jquery ui.

switch class method is one CSS class to another along with managing transition from one state to another in a smooth manner.

Example :

<!doctype html>

<html lang="en">


<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>jQuery UI Effects - switchClass Example</title>

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>



.toggler {

width: 400px;

height: 200px;

position: relative;

border:1px solid #000;



#button {

padding: .5em 1em;

text-decoration: none;


#effect {

position: relative;


.newClass {

width: 220px;

padding: 1em;

letter-spacing: 0;

margin: 0;


.anotherNewClass {

text-indent: 40px;

letter-spacing: .2em;

width: 350px;

height: 100px;

padding: 30px;

margin: 10px;

font-size: 1.1em;



margin:40px auto;

border:1px solid #000;





text-align: center;



background-color: #f2a965;




<h2>JQuery UI Switch Class Example - Nicesnippets.com</h2>

<div class="main-section">

<div class="toggler">

<div id="effect" class="newClass ui-corner-all">

Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede.



<button id="button" class="ui-state-default ui-corner-all">Click Me Run Effect</button>



$( function() {

$( "#button" ).on( "click", function() {

$( ".newClass" ).switchClass( "newClass", "anotherNewClass", 900 );

$( ".anotherNewClass" ).switchClass( "anotherNewClass", "newClass", 900 );






It will help you...


#Jqury UI