Selectors and Events

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

31 Terms

1
New cards

Selectors

The most basic concept of jQuery

2
New cards

jQuery's purpose (via name)

To select some elements and do something with them

3
New cards

jQuery selectors support

Most CSS3 selectors, as well as some non-standard selectors

4
New cards

jQuery syntax structure

$\text{(selector).action()}$

5
New cards

$\text{\$ Sign}$

Denotes the jQuery function

6
New cards

$\text{Selector}$

Selects the HTML element in jQuery syntax

7
New cards

$\text{action()}$

Performs action on the selected element in jQuery syntax

8
New cards

jQuery selectors beginning

All start with the dollar sign and parentheses $\text{\$()}$ followed by action

9
New cards

$\text{\$("*\")}$

Selects all elements

10
New cards

$\text{\$("#id")}$

Selects an element having identifier as id

11
New cards

$\text{\$(".class-name")}$

Selects element with class as class-name

12
New cards

$\text{\$("p:first")}$

Selects first element in a paragraph

13
New cards

$\text{\$("ul li:first")}$

Selects the first $\text{

  • }$ element of the first $\text{
      }$
  • 14
    New cards

    $\text{\$("[href]")}$

    Selects all elements with an $\text{href}$ attribute

    15
    New cards

    $\text{\$:("::button")}$

    Selects all $\text{}$ elements of type="button"

    16
    New cards

    $\text{\$("tr:even")}$

    Selects all even $\text{}$ elements

    17
    New cards

    $\text{\$("tr:odd")}$

    Selects all odd $\text{}$ elements

    18
    New cards

    $\text{\$("div:gt( 2 )")}$

    Selects all $\text{

    }$ elements except the first three

    19
    New cards

    Events

    Play important role in bringing interactivity with users

    20
    New cards

    Source of events

    Many peripherals (ex: mouse)

    21
    New cards

    Event Handling

    Appropriate handling that needs to be done upon events

    22
    New cards

    Vanilla JavaScript event handling implementation

    Done by implementing methods in the HTML element itself

    23
    New cards

    jQuery event handling approach

    Provides better facility to handle events by de-coupling from HTML

    24
    New cards

    $\text{\$ (document).ready()}$

    A function used in examples to ensure code runs after the document is ready

    25
    New cards

    $\text{\$ (this).hide();}$

    Example action taken upon an event, which hides the selected element

    26
    New cards

    Mouse example events

    click

    27
    New cards

    Keyboard example events

    keypress

    28
    New cards

    Form example events

    focus

    29
    New cards

    Window (BOM) example events

    load

    30
    New cards

    $\text{\$ ("#first").text("This is first paragraph");}$

    Example usage to select an element with ID "first" and modify its text

    31
    New cards

    $\text{blur event}$

    Used in an exercise example to change the background colour of input boxes to grey