View Full Version : SVG + Javascript


Aparicio
09-04-2007, 20:30
Boas,
alguém me sabe dizer como alterar texto em SVG (http://www.w3schools.com/svg/default.asp)com javascript?

<text id="texto" x="40%" y="13">Texto a alterar</text>

Normalmente seria feito com document.getElementById('texto').innerHTML="texto"; mas parece que não funciona com SVG.

Aparicio
12-04-2007, 11:25
ninguém? :wvsore:
É que não encontro nada que funcione.

ruimoura
13-04-2007, 22:56
In order to change SVG-elements per javascript one needs to first reference them. This is done using the DOM-tree and DOM methods like document.getElementById(). If references are used more than once, one can store them in global variables, typically initialized by an onload event.

Supostamente funciona.

http://www.carto.net/papers/svg/samples/mouse_over_effects.shtml

Aparicio
14-04-2007, 00:09
Muito obrigado. http://img268.imageshack.us/img268/2803/thumbup6ly.gif

Já tinha experimentado com a propriedade .firstChild, mas faltava-me o .nodeValue