Attribute Ends With [attr$="value"] JQ 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.

The comparison is case sensitive.

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"] Example Selectors  <<  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 purple border around those links. For our example this is all the links within the right sidebar that are not indented and the breadcrumb above.




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


Press the buttons below to action the above code:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors