Changing text in RaphaelJS

孤者浪人 提交于 2020-01-02 01:14:06

问题


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';

回答1:


Try this:

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


来源:https://stackoverflow.com/questions/3490092/changing-text-in-raphaeljs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!