Attribute Ends With [attr$="value"]S2C Home « Selectors « Attribute Ends With [attr$="value"]

Suffix match selector.

Shorthand version  $('[attr$="value"]')

Description

The [attr$="value"] selector, selects all elements that have the specified attribute name with an ending value matching the specified string.

Syntax


Signature Description
jQuery('[attr$="value"]')Suffix match

Parameters


Parameter Description
attrThe attribute name.
valueThe attribute value which can be either an unquoted single word or a quoted string.

Return

N/A.

Attribute Ends With [attr$="value"] Examplego to top of page Top

Selects all elements that have the specified attribute name with an ending value matching the specified string.

The following example will select 'a' elements within 'h3' elements with a 'href' attribute that ends with 'html' and place a white border around those links. For our example this is API reference type and lesson links within the right sidebar.


$(function(){
  $('#btn18').on('click', function() {
    $('h3 a[href$="html"]').css('border', '1px solid white');
  });
}); 

Press the buttons below to action the above code:


go to home page Homepage go to top of page Top