O'Reilly logo

Instant JQuery Selectors by Aurelio De Rosa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting by attributes (Should know)

In this section, we'll see how to select elements by their attributes paying attention to some quirks that can lead to an unexpected behavior.

Getting ready

These selectors are easily recognizable because they are wrapped by square brackets (for example, [selector]). This type of selector is always used coupled with other, like those seen so far, although this can be implicit as we'll see in few moments. In my experience, you'll often use them with the Element selector, but this can vary based on your needs.

How many and what are the selectors of this type? Glad you asked! Here is a table that gives you an overview:

Name

Syntax

Description

Contains

[attribute*="value"]

(for example input[name*="cod"])

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required