Class ('.class')S2C Home « Selectors « Class ('.class')

Class selector.

Shorthand version  $('.class')

Description

The ('.class') selector, selects all the specified direct child elements of the specified parent element.

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') ExampleTop

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: