在 RaphaelJS 中更改文本 [英] Changing text in RaphaelJS

查看:43
本文介绍了在 RaphaelJS 中更改文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 RaphaelJS 创建的文本节点中的文本?首先,我正在使用 Raphael 创建一个带有文本字符串的新元素,稍后我想更改此文本.如果我不必重新初始化元素,那对我来说更容易,因为会附加大量属性,重新创建会很痛苦.有没有办法做到这一点?我的逻辑如下,但它不起作用;它只是为了提供有关我正在努力实现的目标的额外见解.谢谢

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

推荐答案

试试这个:

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

这篇关于在 RaphaelJS 中更改文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆