zakkudesu
8/21/2019 - 6:47 AM

Event Listeners & the Event Object

//Add Event Listener

// document.querySelector('.clear-tasks').addEventListener('click',
// function(e){
//   e.preventDefault;
//   console.log('Hello World');
// });


document.querySelector('.clear-tasks').addEventListener('mouseover',
  onClick);

function onClick(e){
// console.log('Clicked');
let val;
val = e;

//Event target element
val = e.target;
val = e.target.id;
val = e.target.className;
val = e.target.classList;

// e.target.innerText = 'Hello'

//Event Type 
val = e.type;

//Timestamp
val = e.timeStamp;

//Coords event relative to window
val = e.clientY;
val = e.clientX;

//Coords event relative to element
val = e.offsetY;
val = e.offsetX;

console.log(val);
}