niloy / blog

blog raw files
3 stars 1 forks source link

Creating SVG/MathML from JS #10

Open niloy opened 11 years ago

niloy commented 11 years ago

Creating SVG/MathML from JS

Always use createElementNS.

For SVG, the namespace URI is http://www.w3.org/2000/svg. For MathML, http://www.w3.org/1998/Math/MathML.

Some api that work with HTML wont work with these elements. For example, when setting a class in HTML, ele.className = "abc" works, but it wont work for svg & mathml.

Instead use setAttribute.