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
Post a Comment