Get started with randomcolor CDN
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!