Does this code work for anyone else. For the longest time adding an event listener hasn't worked.
<head>
<title>Page Title</title>
<script>
window.onload = init();
function init() {
svg = document.getElementsByTagName('svg');
svg[0].addEventListener('click', mouseClick, false);
}
function mouseClick() {
alert('mouseClicked');
}
</script>
</head>
<body>
<svg><rect x="100" y="100" width="200" height="75"/></svg>
</body>
For every project I've worked on, I've had to use an alternative method. Am I doing something wrong with "addEventListener"? Or what?