ID ('#id') JQ 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') Example Selectors  <<  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:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors