diff options
author | wout <wout@impinc.co.uk> | 2013-03-02 13:23:18 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-03-02 13:23:18 +0100 |
commit | 028bf91551d01567b4cb3d971ba51fa57c4a81ef (patch) | |
tree | aff2f760942f61f2541317a3cf91edcfc15ae077 /README.md | |
parent | e9fa07a7b33b8f19c0690b0fc3df2f57a404d224 (diff) | |
download | svg.js-028bf91551d01567b4cb3d971ba51fa57c4a81ef.tar.gz svg.js-028bf91551d01567b4cb3d971ba51fa57c4a81ef.zip |
Code refactoring on element
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -176,27 +176,39 @@ text.font({ ## Manipulating elements ### Attributes -You can get and set an element's attributes directly using `attr()`: +You can get and set an element's attributes directly using `attr()`. +Get a single attribute: ```javascript -// get a single attribute rect.attr('x') +``` -// set a single attribute +Set a single attribute: +```javascript rect.attr('x', 50) +``` -// set multiple attributes at once +Set multiple attributes at once: +```javascript rect.attr({ fill: '#f06' , 'fill-opacity': 0.5 , stroke: '#000' , 'stroke-width': 10 }) +``` -// set an attribute with a namespace +Set an attribute with a namespace: +```javascript rect.attr('x', 50, 'http://www.w3.org/2000/svg') ``` +Explicitly remove an attribute: +```javascript +rect.attr('fill', null) +``` + + ### Transform With the `transform()` method elements can be scaled, rotated, translated and skewed: |