ID ('#id')S2C Home « Selectors « ID ('#id')

ID selector.

Shorthand version  $('#id')

Description

The ('#id') selector, selects a single element with the specified id attribute value.

Syntax


Signature Description
jQuery('#id')ID match

Parameters


Parameter Description
idAn ID attribute value to search for.

Return

N/A.

ID ('#id') Examplego to top of page Top

Selects a single element with the specified id attribute value.

The following example will select the paragraph with the 'id' attribute of 'backGreen' and turn the background colour green.


$(function(){
  $('#btn13').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