Class ('.class') JQ Home  <<  Selectors  <<  Class ('.class')

Class selector.

Shorthand version $('.class')

Description

The ('.class') selector, selects all elements that have the specified class.

Syntax

Signature Description
jQuery('.class')Class match

Parameters

Parameter Description
classA class value to search for.
(An element can have multiple classes but we only need to match on one of them).

Return

N/A.

Class ('.class') Example Selectors  <<  Top

Selects all elements that have the specified class.

The following example will select any element with a class of 'backGreen' and change the background color to green.




$(function(){
  $('#btn8').on('click', function() {
    $('.backGreen').css('backgroundColor', 'green');
  });
}); 


Press the button below to action the above code:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors