Created
April 14, 2022 04:42
-
-
Save SeePetulaCode/8d27f93585979e84452edb5e830fa681 to your computer and use it in GitHub Desktop.
access to ids in SVG sample
This file contains 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
<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