From ec21f496bddc588e2113fd5418d713ce8ae78f39 Mon Sep 17 00:00:00 2001 From: wout Date: Sun, 22 Jun 2014 11:10:53 +0200 Subject: [PATCH] Updated README --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 23aeaa8..f83ff51 100755 --- a/README.md +++ b/README.md @@ -752,35 +752,31 @@ var element = SVG.get('my_element') element.fill('#f06') ``` -### By CSS selector +### Using CSS selectors There are two ways to select elements using CSS selectors. The first is to search globally. This will search in all svg elements in a document and return them in an instance of `SVG.Set`: ```javascript -var elements = SVG.select('rect.my-class') - -elements.fill('#f06') +var elements = SVG.select('rect.my-class').fill('#f06') ``` The second is to search within a parent element: ```javascript -var elements = group.select('rect.my-class') - -elements.x(100) +var elements = group.select('rect.my-class').fill('#f06') ``` ### Using jQuery -There is no DOM querying system built into svg.js but [jQuery](http://jquery.com/) or [Zepto](http://zeptojs.com/) will help you achieve this. Here is an example: +Another way is to use [jQuery](http://jquery.com/) or [Zepto](http://zeptojs.com/). Here is an example: ```javascript /* add elements */ var draw = SVG('drawing') -var group = draw.group().attr('class', 'my-group') -var rect = group.rect(100,100).attr('class', 'my-element') -var circle = group.circle(100).attr('class', 'my-element').move(100, 100) +var group = draw.group().addClass('my-group') +var rect = group.rect(100,100).addClass('my-element') +var circle = group.circle(100).addClass('my-element').move(100, 100) /* get elements in group */ var elements = $('#drawing g.my-group .my-element').each(function() { -- 2.39.5