Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save clebersonfalk/c831c0caacfcaf2bdd200d8f5739f69d to your computer and use it in GitHub Desktop.
Save clebersonfalk/c831c0caacfcaf2bdd200d8f5739f69d to your computer and use it in GitHub Desktop.
JS - window ready event in pure Javascript, iterate NodeList
(function () {
// Window ready event in pure JS
window.addEventListener('load', ready, false);
function ready () {
changeNum(7);
}
function changeNum (num = 1) {
var n = document.querySelectorAll('.number');
// Iterate NodeList
[].forEach.call(n, function (el) {
el.innerHTML = num;
});
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment