English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery [attribute~=value] Attribute Selector

jQuery Selectors

[ attribute〜= value Selector is used to select elements that contain the specifiedAttributeElements with the specified value.

Syntax:

$("[attribute~=value]")

Example

Select each <img> element that has an alt attribute value (including the word "Parrot"):

$("document").ready(function(){
  $("img[alt~=Parrot]").css("border", ""5px solid red");
});
Test See‹/›

Parameter Value

ParametersDescription
attributeSpecify the attribute name to be selected
valueSpecify the string value to be selected

jQuery Selectors