Friday, February 3, 2017

JS30 Challenge Day 29 - Timers


We can't use:

setInterval(seconds,{
seconds—;
});

Sometimes when the browser is not active, it might pause the setInterval function. Pauses while scrolling in IOS.

*clearInterval alwaysneeds a variable name of a setInterval to stop it.

setInterval does not run immediately.
It needs 1 sec to start.

element.textContent = display;
Note: Use textContent over innerText.
innerText is IE specific and does not cover all elements

document.title can be dynamically set in JS. This updates the title of the webpage.

Remember to clearInterval the timer at the beginning of the timer function.

If an element has a name attribute in html, it can be directly selected as document.elementName in the DOM.

EventListener’s name of the event should always be enclosed in single quotes.

Access the value of an element by element.value;

this.reset();

is used to reset a DOM element like a textbox.

No comments:

Post a Comment