Multiple Attribute [attr="value"][attrn="valuen"] JQ Home  <<  Selectors  <<  Multiple Attribute [attr="value"][attrn="valuen"]

Multiple attribute match selector.

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

Description

The [attr="value"][attrn="valuen"] selector, selects all elements that match all of the specified attribute and value filters

Syntax

Signature Description
jQuery('[attr="value"][attrn="valuen"]')Multiple Attribute match

Parameters

Parameter Description
attrThe attribute name.
valueThe optional attribute value which can be either an unquoted single word or a quoted string.
attrnAs many more attribute names as required.
valuenAs many more optional attribute values as required.

Return

N/A.

Multiple Attribute [attr="value"][attrn="valuen"] Examples Selectors  <<  Top

Selects all elements that match all of the specified attribute and value filters.

The following example will select 'a' elements with a 'href' attribute of '#multiattrb' that contain a 'span' element with a class of 'ital' and turn the background colour yellow.


$(function(){
  $('#btn1').on('click', function() {
    $('a[href="#multiattrb"] span[class="ital"]')
      .css('backgroundColor', 'yellow');
  });
});
 

Press the buttons below to action the above code:

The following example will select left sidebar elements ' that contain a 'link' element with a 'href' attribute that starts with 's' and turn the background colour silver.


$(function(){
  $('#btn2').on('click', function() {
    $('div[class="sidebarleft"] a[href^="s"]')
      .css('backgroundColor', 'silver');
  });
});
 

Press the buttons below to action the above code:

The following example will select 'ul' elements with an id of 'fb' that contain a 'link' element with a 'href' attribute that starts with 'last' and turn the background colour orange.


$(function(){
  $('#btn3').on('click', function() {
    $('ul[id="fb"] a[href^="attrib"]')
      .css('backgroundColor', 'orange');
  });
});
 

Press the buttons below to action the above code:

Related Tutorials

jQuery Basic Tutorials - Lesson 4 - jQuery Selectors

jQuery Basics

jQuery Basics

jQuery Intermediate

jQuery Intermediate

jQuery Advanced

jQuery Advanced

jQuery Reference

API by Function Types

API Alphabetically

jQuery Glossary

Function Type

Ajax

Attributes & Properties

Core & Internals

DOM Element Methods

Effects

Events

Filtering

Manipulation

Objects

Selectors

Attribute

Attribute Contains Prefix Selector

Attribute Contains Selector

Attribute Contains Word Selector

Attribute Ends With Selector

Attribute Equals Selector

Attribute Not Equal Selector

Attribute Starts With Selector

Has Attribute Selector

Multiple Attribute Selector

Basic

All Selector ('*')

Class Selector ('.class')

Element Selector

ID Selector ('#id')

Multiple Selector

Basic Filter

:animated Selector

:eq() Selector

:even Selector

:first Selector

:gt() Selector

:header Selector

:lang Selector

:last Selector

:lt() Selector

:not() Selector

:odd Selector

:root Selector

:target Selector

Child Filter

:first-child Selector

:first-of-type Selector

:last-child Selector

:last-of-type Selector

:nth-child() Selector

:nth-last-child() Selector

:nth-last-of-type() Selector

:nth-of-type() Selector

:only-child Selector

:only-of-type Selector

Content Filter

:contains() Selector

:empty Selector

:has Selector

:parent Selector

Form

:button Selector

:checkbox Selector

:checked Selector

:disabled Selector

:enabled Selector

:file Selector

:focus Selector

:image Selector

:input Selector

:password Selector

:radio Selector

:reset Selector

:selected Selector

:submit Selector

:text Selector

Hierarchy

Child Selector

Descendant Selector

Next Adjacent Selector

Next Siblings Selector

Visibility Filter

:hidden Selector

:visible Selector

Traversal

Utilities