dom & events

7
DOM & Events Document Object Model, Event Loop, Event Bubbling & Events

Upload: chaitanya-kumar-reddy

Post on 14-Apr-2017

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DOM & Events

DOM & EventsDocument Object Model, Event Loop, Event

Bubbling & Events

Page 2: DOM & Events

Event Loop

• JS Engine executes JS in a single threaded way.

• Fakes Concurrency

• What if we write some code that blocks the flow ?

Page 3: DOM & Events

console.log(“Javascript UI/UX Session");function a(x){

console.log(“Starting for a()");b(x);console.log(“Ending of a()");

}function b(y){

console.log(“Starting of b()");console.log("value passed is " +y);console.log(“Ending of b()");

}console.log("Start");a(45);console.log("End");

Page 4: DOM & Events

Event Table & Event Queue

• Any callback(async) function in the code will be added to Event Table.

• Function register itself in Event Table & will wait for the expected event to happen.

• Once event happens Event Table will move the function to Event Queue.

• Event Queue is a staging area, this will move function back to Execution.

Page 5: DOM & Events

DOM

Page 6: DOM & Events

Methods to access DOM

• Finding Elements• Changing Elements• Adding or Removing Elements

Page 7: DOM & Events

Questions???