# Section 1 - Selectors

```
    //boiler
    <html>
    <head>

    </head>
    <body>
        <h1 id ="title"> title </h1>
        <p class="paragraph">Paragraph text 1 </p>
        <p class="paragraph">Paragraph text 2 </p>

        <input type="text"></input>
        <ul>
            <li>List element 1 </li>
            <li>List element 2 </li>
            <li>List element 3 </li>
            <li>List element 4 </li>
            <li>List element 5 </li>
        </ul>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script src="app.js"></script>
    </body>                                            
    </html>
```

### Selectors

* Invoke jquery function -> $()
  * Takes a selector
  * $('selector')

```
    $('.paragraph').css("outline", "1px solid red");
    $('ul').css("outline", "1px solid red");
```

* Work like css elements
  * . for class
  * **for id, etc**

&#x20;classList element 4

```
    $('ul .paragraph').css("outline", "1px solid red");
```

* Specify selectors further by chaining selectors.
* List element 1
* List element 2
* List element 3
* List element 4
* List element 5
* List element 1
* List element 2
* List element 3
* List element 4
* List element 5

```
    $('ul li:first-child').css("outline", "1px solid red");



    //starts counting at 0
    $('ul li:odd').css("outline", "1px solid red");
```

* Selectors by the attribute tag directly:

```
    <p class="paragraph">Paragraph text 1 </p>
    <p class="paragraph">Paragraph text 2 </p>
    <li name = 'anything'>List element 1 </li>



    $('[name]').css("outline", "1px solid red");
    $('[class]').css("outline", "1px solid blue");
```

* Also have the option of specifying attribute tags like this

```
    <p name='more specific'>Paragraph text 2 </p>
    <li name = 'anything'>List element 1 </li>


    $("[name='more specific']").css("outline", "1px solid red");
```

* Selectors as inverses

```
    //Selects everything but the selector
    $("[name!='more specific']").css("outline", "1px solid red");
```

* Shortcuts: selecting all children of a selector
* List element 1
* List element 2

  Paragraph text 1

  Paragraph text 2
* List element 3
* List element 4
* List element 5

```
    $('ul *').css("outline", "1px solid red");
```


---

# 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://maksimdan.gitbook.io/javascript/intro_to_jquery/section_1.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.
