Last active
September 19, 2024 05:56
-
-
Save markvdesign/62a60171069e56cf37932665edbce6b3 to your computer and use it in GitHub Desktop.
funwithsvgscript.svg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg | |
viewBox="0 0 10 10" | |
height="120px" | |
width="120px" | |
xmlns="http://www.w3.org/2000/svg"> | |
<circle cx="5" cy="5" r="4" /> | |
<script> | |
// <![CDATA[ | |
function getColor() { | |
const R = Math.round(Math.random() * 255) | |
.toString(16) | |
.padStart(2, "0"); | |
const G = Math.round(Math.random() * 255) | |
.toString(16) | |
.padStart(2, "0"); | |
const B = Math.round(Math.random() * 255) | |
.toString(16) | |
.padStart(2, "0"); | |
return `#${R}${G}${B}`; | |
} | |
document.querySelector("circle").addEventListener("click", (e) => { | |
e.target.style.fill = getColor(); | |
}); | |
// ]]> | |
</script> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment