# 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="https://4208221935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnkRd0l7hxCM4iKa5tj2m%2Fuploads%2FWRPYxnooIjCAAawk7k2k%2Fclass-name.png?alt=media&#x26;token=46984a14-bca7-42cf-9735-69dd3d6edef3" 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="https://4208221935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnkRd0l7hxCM4iKa5tj2m%2Fuploads%2FKiNMAUe4NEnjF592aRct%2Fcombo-class.png?alt=media&#x26;token=1616034f-898c-4e99-89f8-ab58dba10205" 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="https://4208221935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnkRd0l7hxCM4iKa5tj2m%2Fuploads%2FOETuWSO4uVrrloT8DcN5%2Fchild-class.png?alt=media&#x26;token=b0d60082-9d6d-4910-9ebc-6ede5b15d2e4" 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="https://4208221935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnkRd0l7hxCM4iKa5tj2m%2Fuploads%2FdUJImqlw3XKoqKEGZUEQ%2Fattribute.png?alt=media&#x26;token=91763811-6f6f-4bde-bb92-6ec70f46a8f4" 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="https://4208221935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnkRd0l7hxCM4iKa5tj2m%2Fuploads%2FDMhYt4jsRzUmY5DAq4QM%2FInspect.png?alt=media&#x26;token=b04e2aa8-313e-41d9-af26-e018abdbb980" 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 %}
