From: Ulrich-Matthias Schäfer Date: Sun, 25 Oct 2015 22:03:47 +0000 (+0100) Subject: updated docs X-Git-Tag: 2.2.0~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=81917ee7c714d0d7e3db4ec6471b734b62c63bfe;p=svg.js.git updated docs --- diff --git a/README.md b/README.md index 13753db..c22f633 100644 --- a/README.md +++ b/README.md @@ -936,6 +936,23 @@ element.parent() __`returns`: `element`__ +Alternatively a class or css selector can be passed as the first argument: + +```javascript +var draw = SVG('drawing') +var nested = draw.nested().addClass('test') +var group = nested.group() +var rect = group.rect(100, 100) + +rect.parent() //-> returns group +rect.parent(SVG.Doc) //-> returns draw +rect.parent(SVG.Nested) //-> returns nested +rect.parent(SVG.G) //-> returns group +rect.parent('.test') //-> returns nested +``` + +__`returns`: `element`__ + Even the main svg document: ```javascript @@ -948,7 +965,7 @@ __`returns`: `HTMLNode`__ ### doc() -For more specific parent filtering the `doc()` method can be used: +For retrieving the root svg you can use `doc()` ```javascript var draw = SVG('drawing') @@ -957,21 +974,6 @@ 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 -``` -__`returns`: `element`__ - ## Child references ### first()