Events Flashcards

1
Q

Which browser is the addEventListener not compatible with?

A

addEventListener method will not work with legacy browsers from iexplorer 8 and earlier. You are required to call .attachEvent using arguments of ‘onclick’ and function call , it does not use a propagation parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the benefits of using eventListener in comparison to calling by documentbyId

A

eventListener allows for event propagation meaning that you can write one function to handle events from multiple sources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the key arguments of eventListener?

A

it takes the event literal , like click , the function and the propagation status (true or false)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you set an listener for an event using jquery?

A

use selector $() and on method , the on method takes the same parameters as addEventListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are main examples of coordinate info events?

A

screen x,y , client x,y , layer x, y, page x,y offset x,y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between screenX,Y and clientX,Y ?

A

screen gives user position relative to the user screen while client gives it relative to window.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Event info?

A

event type, event timestamp and defaultPrevented

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are events related to targeting information

A

target - element that the event originated from, srcElement - actual element that fired the event.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

fromElement and toElement deal which which events?

A

mouseover and mouseout events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is offsetXY

A

Gives the position relative to the element that fires the event.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are examples of events that provide key/mouse information?

A

altKey , charCode/KeyCode , button , ctrKey and shiftKey

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does layerX,Y coordinate info do?

A

Shows the position of the element relative to another positioned event - not all browsers use this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does pageXY coordinate info do?

A

Will give you the event relative to the HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

charCode/KeyCode

A

Detects which character was pressed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which events handle which modifier code is pressed?

A

altKey, ctrlKey and shiftKey

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the characteristics of event propagation?

A

An element can capture child events, it is a good reason to use addEventListener() , not compatable with browsers older than IE8

17
Q

What are the ways that browsers register the event?

A

The bubbling phase which captures from the lowest element and passes it up the chain of element hierarchy. Bubbling goes up the DOM chain.
Capturing it goes down the DOM.

18
Q

what method can you use to stop events from propagating in the DOM?

A

the stopPropagation() method can be used. prevents further propagation of the current event

19
Q

what method is used to prevent a default behaviour from occurring when an event is triggered?

A

the preventDefault() method is used. A useful method in validating and controlling information.

20
Q

when handling events in addEventListener what does the argument false result in?

A

False sets the event to bubble up the page instead of being captured.

21
Q

What method can you use to select the parent of a clicked element in the DOM?

A

Use e.target.parentNode;

22
Q

How do you remove a node ?

A

use node.removeChild(child); where node is parent and child is the node to be removed.

var node = e.target.parentNode;

 if (node) {
    node.parentNode.removeChild(node);
}
23
Q

How do you create an class name?

A

Use element.className = “name”

24
Q

How do you create an element?

A

Use document.createElement(div)

25
Q

How do you attach an element to a target?

A

Use e.target.appendChild( < element> )

26
Q

What method is used to access the partner of a targeted object?

A

Use e.target.parentNode