Attribute Contains [attr*="value"]S2C Home « Selectors « Attribute Contains [attr*="value"]

Substring match selector.

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

Description

The [attr*="value"] selector, selects all elements with the specified attribute name and a value containing the specified string.

Syntax


Signature Description
jQuery('[attr*="value"]')Substring 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 Contains [attr*="value"] Examplego to top of page Top

Selects all elements with the specified attribute name and a value containing the specified string.

The following example will select 'input' elements on the page that have a value attribute containing the word 'urn' and change their background color to orange or yellow (look at the two buttons below).


$(function(){
  $('#btn16').on('click', function() {
    $('input[value*="urn"]').css('backgroundColor', 'orange');
  });
  $('#btn17').on('click', function() {
    $('input[value*="urn"]').css('backgroundColor', 'yellow');
  });
}); 

Press the buttons below to action the above code:

            


go to home page Homepage go to top of page Top