Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeePetulaCode/8d27f93585979e84452edb5e830fa681 to your computer and use it in GitHub Desktop.
Save SeePetulaCode/8d27f93585979e84452edb5e830fa681 to your computer and use it in GitHub Desktop.
access to ids in SVG sample
<script>
var a = document.getElementById("alphasvg");
// It's important to add an load event listener to the object,
// as it will load the svg doc asynchronously
a.addEventListener("load",function(){
// get the inner DOM of alpha.svg
var svgDoc = a.contentDocument;
// get the inner element by id
var delta = svgDoc.getElementById("delta");
// add behaviour
delta.addEventListener("mousedown",function(){
alert('hello world!')
}, false);
}, false);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment