2
I want to change the text of the text tag with Javascript.
<text id =txtrect x="5" y="35" font-family="Verdana" font-size="11" fill="white" >
Rect
</text>
I tried this but it doesn’t change
document.getElementById(txtrect).innerHTML=teste;
2
I want to change the text of the text tag with Javascript.
<text id =txtrect x="5" y="35" font-family="Verdana" font-size="11" fill="white" >
Rect
</text>
I tried this but it doesn’t change
document.getElementById(txtrect).innerHTML=teste;
4
Change to:
<text id="txtrect" x="5" y="35" font-family="Verdana" font-size="11" fill="white" >
Rect
</text>
and
document.getElementById("txtrect").innerHTML="teste";
That should solve your problem.
Update
I advise you to take a look at this tutorial: http://www.w3schools.com/js/js_htmldom_methods.asp Will solve your problems with javascript.
-1
Just do it like this:
document.querySelector("#txtrect").innerHTML ="Teste";
<text id =txtrect x="5" y="35" font-family="Verdana" font-size="11" fill="white" >
Rect
</text>
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
Try to replace
ìd =txtrect
forid="txtrect"
anddocument.getElementById(txtrect).innerHTML=teste;
fordocument.getElementById("txtrect").innerHTML = "teste";
And study the javascript syntax. In programming, each comma can change the result. These missing quotes denote that you are starting. So from now on, pay more attention when typing code. Not to mention that attributesx
andy
should not exist.– Guill