Having trouble applying style to SVG using JavaScript upon object creation

Posted by Jack Roscoe on Stack Overflow See other posts from Stack Overflow or by Jack Roscoe
Published on 2010-06-08T12:39:29Z Indexed on 2010/06/08 12:42 UTC
Read the original article Hit count: 141

Filed under:
|

Hi,

I have a function which creates an SVG text object using JavaScript. As soon as the object is created, I want it to have the style attribute which in CSS would be text-anchor: left.

Currently, it doesn't work. I have tried many variations, and I also read that when using styles in JavaScript you must remove any '-' dashes and format the attribute name in camel casing (is this true?).

Can anybody spot my mistake? Here's my code:

    RenderTextBox:function()
{
    this.textBox = paper.text(this.x, this.y, this.htmlTextBox);
    this.textBox.style.textAnchor="left";
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css