I want to embed a SVG within my HTML, and use Jquery to bind events on it. But I am getting unexpected results with my Jquery calls. This sometimes results in Uncaught ReferenceError: sayHello is not defined in my browser. But at other times, it simply does not correctly bind the console printing to the click event.
<a href='#'> Click me! </a>
<embed id='board' src="tictactoe.svg" height="100%" width="100%" style="border:solid #999 1" >
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100" onload="sayHello()">
...
</svg>
function sayHello() {
$('a').on('click',function(e){e.preventDefault(); console.log('hello');});
}