diff options
author | wout <wout@impinc.co.uk> | 2014-01-25 15:19:44 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-01-25 15:19:44 +0100 |
commit | 4eb82d6002258266717ab2edf1a686c3e2fb31fd (patch) | |
tree | fd37e96128482f04be7ed30ad58998b6df76aa6b /README.md | |
parent | b48f03348ba04fb875c193f7e630fb35601bd9fe (diff) | |
download | svg.js-4eb82d6002258266717ab2edf1a686c3e2fb31fd.tar.gz svg.js-4eb82d6002258266717ab2edf1a686c3e2fb31fd.zip |
Updated README and version references
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -456,6 +456,44 @@ Similarly, the node carries a reference to the svg.js `instance`: node.instance ``` +### Parent reference +Every element has a reference to its parent: + +```javascript +element.parent +``` + +Even the main svg document: + +```javascript +var draw = SVG('drawing') + +draw.parent //-> returns the wrappig html element with id 'drawing' +``` + +For more specific parent filtering the `doc()` method can be used: + +```javascript +var draw = SVG('drawing') +var rect = draw.rect(100, 100) + +rect.doc() //-> returns draw +``` + +Alternatively a class can be passed as the first argument: + +```javascript +var draw = SVG('drawing') +var nested = draw.nested() +var group = nested.group() +var rect = group.rect(100, 100) + +rect.doc() //-> returns draw +rect.doc(SVG.Doc) //-> returns draw +rect.doc(SVG.Nested) //-> returns nested +rect.doc(SVG.G) //-> returns group +``` + ## Manipulating elements |