# Childfilters

Een childfilter selecteert het n-de element binnen het parent element.\
Zie : <http://api.jquery.com/category/selectors/child-filter-selectors/>

## Eerste child element :first-child

```javascript
$('p b:first-child')   // de eerste b-tag in ELKE paragraaf
$('h3:first-child')    // alle h3-tags die een eerste child zijn van een (willekeurige) parent
```

## Laatste child element :last-child

```javascript
$('p b:last-child')   // de laatste b-tag in ELKE paragraaf
$('p:last-child')     // alle paragrafen die een laatste child zijn van een (willekeurige) parent
```

## Eerste sibling element binnen dezelfde parent :first-of-type

```javascript
$('a:first-of-type')         // de eerste a-tag binnen dezelfde parent
```

## Laatste sibling element binnen dezelfde parent :last-of-type

```javascript
$('a:last-of-type')          //de laatste a-tag binnen dezelfde parent
```

## n-de child elementen

De index start hier vanaf ***1*** en niet vanaf ***0***!\
De letter **n** staat voor een geheel getal (0, 1, 2, 3, ...).

```javascript
$('p b:nth-child(2)')           // de tweede b-tag in elke paragraaf
$('p b:nth-child(3n)')          // b-tags 3, 6, 9, ... in elke paragraaf
$('p b:nth-child(even)')        // alle even b-tags in elke paragraaf
$('p b:nth-child(2n)')          // alle even b-tags in elke paragraaf
$('p b:nth-child(odd)')         // alle oneven b-tags in elke paragraaf
$('p b:nth-child(2n+1)')        // alle oneven b-tags in elke paragraaf
$('p b:nth-last-child(2)')      // de voorlaatste b-tag in elke paragraaf
$('li:nth-of-type(even)')       // alle even li-tags binnen dezelfde parent
$('a:nth-last-of-type(2)')      // de voorlaatste a-tag binnen dezelfde parent
```

## Het enige child element :only-child()

```javascript
$('p b:only-child()')   // de b-tag, maar ENKEL indien dit HET ENIGE child element binnen de p-tag is
```

## Het enige child element van dat type binnen dezelfde parent :only-of-type()

```javascript
$('b:only-of-type()')   // de b-tag, maar ENKEL indien dit DE ENIGE b-tag is binnen dezelfde parent
```


---

# 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://1itf.gitbook.io/jquery/4-elementen-selecteren/childfilters.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.
