Please look at the following code. I cannot for the life of me figure out what's wrong with the JavaScript that hinders the onclick event. The CSS styling is working well, of course, but even though the JS works as-is on codepen, it won't work here.
<svg id="mySVG" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<style>
#mySVG {
cursor: pointer;
}
@keyframes circleGrow {
to {r:50}
}
#myCircle {
animation: circleGrow 1s 1s forwards;
}
@keyframes strokeDraw {
to {stroke-dashoffset: 0}
}
@keyframes toFill {
to {fill: white;}
}
#myText {
animation: strokeDraw 2.5s 2s linear forwards,
toFill 1s 4.5s linear forwards;
}
</style>
<script>
//<![CDATA[
var mySVG = document.getElementById("mySVG"),
myCircle = document.getElementById("myCircle"),
myText = document.getElementById("myText");
mySVG.onclick = function(){
myCircle.style.animation = "null";
myText.style.animation = "null";
setTimeout(function(){
myCircle.style.animation = "";
myText.style.animation = "";
},10);
}
//]]>
</script>
<circle id="myCircle" cx="50" cy="50" r="0" fill="maroon" />
<text id="myText" x="50%" y="50%" text-anchor="middle" alignment-baseline="central" font-size="40" fill="transparent" stroke="white" stroke-dasharray="190" stroke-dashoffset="190">Hello</text>
</svg>