javascript - d3 select throws invalid query selector error -


this structure of svg elements:

<g class="point" transform="translate(241,197)">   <circle></circle>   <text class="pointindex" x="-4px" y="-10px">1</text>   <g class="deletepoint" transform="translate(0,16)">     <circle></circle>     <text x="-3px" y="3px">x</text>   </g> </g> 

i created following function:

  function deletepoint(deletecircle) {     var circletext = d3.select(deletecircle.parentnode + '> text')   } 

console.log(deletecircle) returns:

 <g class="deletepoint" transform="translate(0,16)">     <circle></circle>     <text x="-3px" y="3px">x</text>  </g> 

what want find text here: <text class="pointindex" x="-4px" y="-10px">1</text> (in case 1) did deletecircle.parentnode + ' .pointindex'. following error:

uncaught syntaxerror: failed execute 'queryselector' on 'document': '[object svggelement] .pointindex' not valid selector.

why happening , how fix it?

here deletecircle.parentnode html element , cannot concat string , use selector.

you can text content shown below, deletecircle circle element.

var circletext = d3.select(deletecircle.parentnode).select("text").text(); 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -