Get started with randomcolor CDN

MIT licensed

Program/function generates random color value - Randomcolor term.

Tags:
  • color
  • random

Stable version

Copied!

How to start using randomcolor CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with randomcolor CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/randomColor.min.js"></script>
</head>
<body>
  <button id="generate">Generate Random Color</button>
  <div id="colorBox"></div>

  <script>
    const generateBtn = document.getElementById('generate');
    const colorBox = document.getElementById('colorBox');

    function generateRandomColor() {
      const randomColor = new RandomColor();
      const color = randomColor.random();
      colorBox.style.backgroundColor = color.hex();
    }

    generateBtn.addEventListener('click', generateRandomColor);
    generateRandomColor(); // Initial color
  </script>
</body>
</html>
Copied!
Copied!

All versions