Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142188

Trying to create a color change application using the DOM in javascript

$
0
0

This is the Javascript Code. The HTML is just a button tag and the link to a specific stylesheet and the script.

  let color = ["#F1FF06", "#A5FF06", "#59FF06", "#FF6506", "#FF1E06", "#B0736C", "#B0A56C", "#06EA9D", "#06EA9D", "#06EA9D","#98D8DE","#D098D1", "#770C79","#000000","#2F062E", "#F6F6F6"]
  let i = 0;
  document.querySelector("button").addEventListener("click",  function(){
    i = i < color.length ? ++1 : 0;
  document.querySelector("body").style.background = color[i];
  })

Viewing all articles
Browse latest Browse all 142188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>