Layout Options

  • Fixed Header
    Makes the header top fixed, always visible!
  • Fixed Sidebar
    Makes the sidebar left fixed, always visible!
Introduction
Webconcept

Description

The .addClass() method adds one or more classes to the selected elements.

This method does not remove existing class attributes, it only adds one or more values to the class attribute.

Tip: To add more than one class, separate the class names with space.


v1.0

This method has the form:

.addClass(class)
Parameter Description
class (required) Specifies one or more class names to be added

Return Value

This form returns a jQuery object.


Add Class Using a Function

Using a function to add classes to selected elements.

v1.4

This method has the alternate form:

.addClass(function(index,oldclass))
Parameter Description
function(index, oldclass) (required) Specifies a function that returns one or more class names to be added.
  • index - (optional) Receives the index position of the selector
  • oldclass - (optional) Receives the old class value of the selector

Return Value

This form returns a jQuery object.

Examples

Add a class to the first p element:

$("button").click(function(){
  $("p:first").addClass("intro");
});

Description

The .removeClass() method removes one or more classes from the selected elements.

Note: If no parameter is specified, this method will remove ALL classes from the selected elements.


v1.0

This method has the form:

.removeClass(classname)
Parameter Description
classname (optional) Specifies one or more class names to remove. To remove several classes, separate the class names with space.

Note: If this parameter is empty, all classes will be removed.

Return Value

This form returns a jQuery object.


Remove Class Using a Function

Using a function to remove a class from the selected elements.

v1.4

This method has the alternate form:

.removeClass(function(index,oldclass))
Parameter Description
function(index, oldclass) A function that returns one or more class names to remove.
  • index - (optional) Receives the index position of the selector
  • oldclass - (optional) Receives the old class value of the selector

Return Value

This form returns a jQuery object.

Examples

Remove the class "intro" from all p elements:

$("button").click(function(){
  $("p").removeClass("intro");
});