Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A node created with RaphaelJS has a <code>raphaelid</code> property or something very close you can log in Chrome DevTools or similar. </p> <p>Since you know this specific ID and you have a reference to the Raphael <code>Paper</code> instance as the <code>paper</code> variable for instance, you get the element with: </p> <pre><code>paper.getById(node.raphaelid) </code></pre> <p>Actually, this is quite undocumented. Only the <code>getById</code> method is documented in the <a href="http://raphaeljs.com/reference.html#Paper.getById" rel="nofollow">RaphaelJS documentation (Paper.getById section)</a></p> <p><strong>Update for the comment about not being able to get raphaelid on the DOM element</strong></p> <p>Please have a look at this <a href="http://jsfiddle.net/7xCFL/" rel="nofollow">jsfiddle about getting raphaelid</a>.</p> <p>HTML</p> <pre><code>&lt;div id="c"&gt;&lt;/div&gt; &lt;div&gt;&lt;code&gt;rect.node.raphaelid&lt;/code&gt; : &lt;span id="i"&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;code&gt;rect2.node.raphaelid&lt;/code&gt; : &lt;span id="i2"&gt;&lt;/span&gt;&lt;/div&gt; </code></pre> <p>JS</p> <pre><code>var paper = Raphael(c,400,400); var rect = paper.rect(100,100,200,200); var rect2 = paper.rect(150,150,200,200); i.textContent = rect.node.raphaelid; i2.textContent = rect2.node.raphaelid; </code></pre> <p>Text result</p> <blockquote> <p>rect.node.raphaelid : 0 </p> <p>rect2.node.raphaelid : 1</p> </blockquote> <p>All this with version 2.1.0 of RaphaelJS</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload