I'm creating a family tree using SVG, a small structure is given below. I need help to add specific class(say 'selected') on mouse over on the class - "node", on every first "rect" of "g" which is the parents of the current hovered "node".
$this.addClass('classname') is not working. So I m using $this.attr('class','classname')
Impotent : I need a function like parents ( - in jQuery ) or similar methods to get all parent "g" of the current hovered "rect".
current work - click here
A sample structure.
<svg style="width:100%;height:455px" id="svg_root" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<g id="viewport" >
<g id="1">
<rect class="node" y="0" x="0" width="160" height="35" />
<text class="prof_name" y="14" x="34">Name</text>
<g id="2">
<rect class="node" y="40" x="30" width="160" height="35" />
<text class="prof_name" y="54" x="64">Name</text>
<g id="7">
<rect class="node" y="80" x="90" width="160" height="35" />
<text class="prof_name" y="94" x="94">Name</text>
</g>
</g>
</g>
<g id="18">
<rect class="node" y="120" x="0" width="160" height="35" />
<text class="prof_name" y="134" x="34">Name</text>
</g>
</g>
</svg>
I think jQuery is not friendly with SVG :(