Saturday, September 21, 2019

jQuery UI removeClass

The jQuery removeClass() method is used to manage jQueryUI visual effects. It removes applied classes from the elements.

removeClass() method removes the specified classes to the matched elements while animating all style changes.

Syntax:

Following is a basic syntax of jQueryUI removeclass() method: (Added in version 1.0 of jQueryUI)

  1. .removeClass( className [, duration ] [, easing ] [, complete ] )  
Parameters of removeClass() method:
  • ClassName: This is a string which contains one or more CSS classes. (In case of more CSS classes, they are separated by space.)
  • Duration:This is used to specify the time duration in milliseconds. The 0 value takes the element directly to the new style, without progress. Its default value is 400.
  • Easing: It is a type string and indicates the way to progress in the effect. Its default value is swing.
  • Complete: It is a callback method call for each element when the when the effect is completed for this element.
Syntax for jQuery removeClass method: (Added in version 1.9)
The new version 1.9 of jQueryUI also supports children option, which will also animate descendant elements.
Syntax:
  1. .removeClass( className [, options ] )   
Parameters of removeClass() method in version 1.9:
className:This is a string which contains one or more CSS classes. (In case of more CSS classes, they are separated by space.)
options: It is used to specify all animation settings. All properties are optional. Its possible values are:
  • Duration:This is a type of number or string and indicates the time duration of the effect. It is counted in millisecond. The value of 0 takes the element directly in the new style, without progress. Its default value is 400.
  • Easing:It is a string. It specifies the way to progress in the effect. Its default value is swing.
  • Complete:It is a callback method called for each element when the effect is done for this element.
  • Children: This is a Boolean type and specifies whether the animation should additionally be applied to all descendants of the matched elements. Its default value is false.
  • Queue:This is of Boolean type or string type and specifies whether to place the animation in the effects queue. Its default value is TRUE.

jQuery UI removeclass example

Let's take an example to demonstrate the jQueryUI removeclass()(Passing single class)
  1. <!DOCTYPE html>  
  2. <html>  
  3.    <head>  
  4.       <meta charset="utf-8">  
  5.       <title>jQuery UI addClass Example</title>  
  6.       <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">  
  7.       <script src="http://code.jquery.com/jquery-1.10.2.js"></script>  
  8.       <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  
  9.       <style>  
  10.          .elemClass {  
  11.             width: 300px;  
  12.             height: 100px;  
  13.             background-color: #76eec6;  
  14.          }  
  15.          .myClass {  
  16.             font-size: 30px; background-color: #eed5b7; color: #0000ee;  
  17.          }  
  18.       </style>  
  19.       <script type="text/javascript">  
  20.          $(document).ready(function() {  
  21.             $('.button').click(function() {  
  22.                if (this.id == "add") {  
  23.                   $('#animTarget').addClass("myClass", "fast")  
  24.                } else {  
  25.                $('#animTarget').removeClass("myClass", "fast")  
  26.                }  
  27.             })  
  28.          });  
  29.       </script>  
  30.    </head>  
  31.    <body>  
  32.       <div id=animTarget class="elemClass">  
  33.          Hello! JavaTpoint  
  34.       </div>  
  35.       <button class="button" id="add">Add Class</button>  
  36.       <button class="button" id="remove">Remove Class</button>  
  37.    </body>  
  38. </html>  

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...