title: Change theme-color via JavaScript (mobile chrome tab color)
body: <p>I wanted to create a hex color clock that changes the background color of the site + the theme-color (mobile chrome tab color).
  The clock with the changing background is working, the theme-color on the other hand is not changing.</p>
  
  <p>This is what I got so far.</p>
  
  <pre><code>&lt;html lang="en"&gt;
     &lt;head&gt;
        &lt;meta charset="UTF-8"/&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
        &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"/&gt;
        &lt;meta name="theme-color" content="#ffffff"&gt;
        &lt;link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"&gt;
        &lt;title&gt;Hex Clock&lt;/title&gt;
        &lt;link rel="stylesheet" href="css/style.css" /&gt;
     &lt;/head&gt;
     &lt;body&gt;
        &lt;div class="absolute-center"&gt;
        &lt;p id="hex"&gt;&lt;/p&gt;
        &lt;div&gt;
        &lt;script src="js/app.js"&gt;&lt;/script&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <pre><code>var hexColor = document.getElementById('hex');
  var time = new Date();
  var hours = time.getHours().toString();
  var minutes = time.getMinutes().toString();
  var seconds = time.getSeconds().toString();
  var hexColorStr = '#' + hours + minutes + seconds;
  var metaThemeColor = document.querySelector("meta[name=theme-color]");
  
  function hexClock() {
  
  
    if (hours.length &lt; 2) {
      hours = '0' + hours;
    }
  
    if (minutes.length &lt; 2) {
      minutes = '0' + minutes;
    }
  
    if (seconds.length &lt; 2) {
      seconds = '0' + seconds;
    }
  
  
    metaThemeColor.setAttribute("content", hexColorStr);
    hexColor.textContent = hexColorStr;
    document.body.style.backgroundColor = hexColorStr;
  }
  
  hexClock();
  setInterval(hexClock, 1000);
  </code></pre>
  
  <p>I tried this code <a href="https://gordonlesti.com/change-theme-color-via-javascript/" rel="nofollow noreferrer">https://gordonlesti.com/change-theme-color-via-javascript/</a>, it worked by it self but as soon as I implemented it in my code it stopped working. </p>