Reputation: 29
I use SVG inisde my xhtml file. I can not get access to the text with id="Wert". What is wrong, I want to change the color form blue to red.
Untitled Page
<script type="text/javascript">
function OnLoad() {
setTimeout("timer()", 1000);
}
function timer() {
var randomnumber = Math.floor(Math.random() * 101); // Zahlen von 0..100
var svgdocument = document.svgid.getSVGDocument( 'svgid');
svgtext = svgdocument.getElement.ById('Wert');
svgtext.setattribute('style','fill:red');
setTimeout("timer()", 1000);
}
</script>
40
Upvotes: 2
Views: 455
Reputation: 944320
function OnLoad()
should be onload = function ()
(case sensitive!)setInterval
instead of repeatedly calling setTimeout
document.id_of_element
except in some versions of IE (use getElementById instead)setAttribute
has a capital A in the middle of itUpvotes: 5