Has Attribute [attr]S2C Home « Selectors « Has Attribute [attr]

Has attribute selector.

Shorthand version  $('[attr]')

Description

The [attr] selector, selects all elements that have the specified attribute name.

Syntax


Signature Description
jQuery('[attr]')Attribute match

Parameters


Parameter Description
attrThe attribute name.

Return

N/A.

(':first-child') Examplego to top of page Top

Selects all elements that have the specified attribute name.

The following example will select all 'href' attributes on the page and change their color to purple (all links on the page).


$(function(){
  $('#btn12').on('click', function() {
    $([href]).css('color', 'purple');
  });
}); 

Press the button below to action the above code:


go to home page Homepage go to top of page Top