wes
wes

Reputation: 734

Changing text in RaphaelJS

How may I change the text in a RaphaelJS-created text node? First, I am creating a new element with a text string with Raphael, and at some later point I would like to change this text. It's easier for me if I do not have to reinitialize the element as there will be a whole host of attributes attached that will be a pain to recreate. Is there a way to do this? I've got my logic below, but it doesn't work; it's there just to provide extra insight as to what I'm trying to achieve. Thanks

var R = Raphael("graph-o-matic", 1000, 1000);

var title = R.text( 10, 10, 'original text');

...

title.text.innerHTML = 'nifty new text here';

Upvotes: 11

Views: 5339

Answers (1)

robertc
robertc

Reputation: 75707

Try this:

title.attr({text: 'nifty new text here'});

Upvotes: 34

Related Questions