Element ('element')S2C Home « Selectors « Element ('element')

Element selector.

Shorthand version  $('element')

Description

The ('element') selector, selects all elements that have the specified tag name.

Syntax


Signature Description
jQuery('element')Element match

Parameters


Parameter Description
element An element to search for (this refers to the tagName of DOM nodes).

Return

N/A.

Element ('element') Examplego to top of page Top

Selects all elements that have the specified tag name.

This method calls JavaScript's getElementsByTagName() function 'under the hood' to return the appropriate elements when used.

The following example will select all 'em' elements and change the text colour of these elements to green.


$(function(){
  $('#btn10').on('click', function() {
    $('em').css('color', 'green');
  });
}); 

Press the button below to action the above code:


go to home page Homepage go to top of page Top