Posts

All "event" properties in Javascript ?

// Common Event Properties event.type;               // Type of the event (e.g., "click", "keydown"). event.target;             // Element that triggered the event. event.currentTarget;      // Element to which the event handler is attached. event.bubbles;            // Boolean indicating if the event bubbles up through the DOM. event.cancelable;         // Boolean indicating if the event can be canceled. event.defaultPrevented;   // Boolean indicating if preventDefault() was called. event.eventPhase;         // Current phase of event propagation (1 = capturing, 2 = at target, 3 = bubbling). event.isTrusted;          // Boolean indicating if the event was generated by a user action or script. event.timeStamp;          // Time when the event was created. // Comm...

JavaScript Window CSS

let element = document.querySelector('pre'); let previousContent = element.textContent; // add event listener element.addEventListener('mouseenter',(e)=>{ e.target.textContent = window.getComputedStyle(e.target)["cursor"]; }); // add event listener to get back to previous one element.addEventListener('mouseleave',(e)=>{ e.target.textContent =  previousContent; }); or element .addEventListener('mouseenter',( e )=>{ // let the cursor style display on pre tag for 5 seconds only for that we're using setTimeout() setTimeout(()=>{ e .target.textContent = window.getComputedStyle( e .target)["cursor"]; }, 5000); }); ==================================================================  let events = ["mouseenter","mouseleave"]; let element = document.querySelector('pre'); events.forEach((e)=>{ element.textContent = window.getComputedStyle(element.target)["cursor"]; }); =====================...