at each click, add an element red color, when all elements are red, then one click from the end will return black color to the elements, how can this be done? html:
<ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> <button id="btn">click</button> Js:
function ready() { var i = 0; document.getElementById("btn").onclick = function() { var list = document.getElementsByTagName("li"); for (i; i < list.length;) { list[i].style.color = "red"; i++; return; } }; }; document.addEventListener("DOMContentLoaded", ready);