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

Class selector.

Shorthand version  $('.class')


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


Signature Description
jQuery('.class')Class match


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



Class ('.class') Examplego to top of page 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.

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

Press the button below to action the above code:

go to home page Homepage go to top of page Top