# Selecting Elements

When we target something using jQuery, it selects every element on the page that matches that selector.

***

## Selecting by class name

Class names in Webflow should not contain spaces, capital letters, or start with a number.

{% code overflow="wrap" %}

```javascript
$(".class-name")
```

{% endcode %}

<div align="left"><figure><img src="/files/fpHVjtDqZLS8jMtl5bM4" alt="" width="299"><figcaption></figcaption></figure></div>

### Selecting by class name & combo class

Only selects hero-card elements that have a combo class of is-featured

```javascript
$(".hero-card.is-featured")
```

<div align="left"><figure><img src="/files/kETyKx8mNQWzVaW8fe17" alt="" width="297"><figcaption></figcaption></figure></div>

### Selecting an element inside of another element

Only selects dark-card elements that are inside of the hero-grid

```javascript
$(".hero-grid .dark-card")
```

<div align="left"><figure><img src="/files/Z4YIm66RvyrRkaI2tCZr" alt="" width="248"><figcaption></figcaption></figure></div>

&#x20;

***

## Selecting by data attribute name & value

{% code overflow="wrap" %}

```javascript
$("[attribute-name='attribute-value']")
```

{% endcode %}

<div align="left"><figure><img src="/files/qY7YPdCLxwn7COBsdq77" alt="" width="299"><figcaption></figcaption></figure></div>

&#x20;

***

## Selecting by html tag

{% code overflow="wrap" %}

```javascript
// H2 Headings
$("h2")
// Paragraphs
$("p")
// Links
$("a")
// Images
$("img")
// Videos
$("video")
// HTML Buttons
$("button")
// Inputs
$("input")
// Text Areas
$("textarea")
// Select Fields
$("select")
```

{% endcode %}

We can target any element by its html tag. If unsure of the tag name, right click on any element & inspect on the published site to find its tag.

<div align="left"><figure><img src="/files/fTtOvfYzKCiEpmICfX1y" alt="" width="563"><figcaption></figcaption></figure></div>

&#x20;

***

## Selecting multiple elements

### Chaining selectors

We can chain together multiple selectors by using commas to select different elements together.

{% code overflow="wrap" %}

```javascript
$(".class-name, h2, [attribute-name='attribute-value'], .another-class")
```

{% endcode %}

### .add() method

We can also use the .add() method to select multiple elements. This is more useful for selecting multiple elements once they're already saved in separate variables.

{% code overflow="wrap" %}

```javascript
$(".class-one").add(".class-two").add(".class-three")
```

{% endcode %}

{% code overflow="wrap" %}

```javascript
let elementOne = $(".class-name");
let elementTwo = $("h2");

elementOne.add(elementTwo).text("Hello");
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jquery.timothyricks.com/selecting-elements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
