d3 Trying to select text within a svg text element

d3.js, getter, svg, text

Solution

You can do this by running

var text = d3.select(this).text();

Problem

I have an SVG text element: ``` <text class="countries" dy="0" dx="-339.87646027037385" font-size="22" style="fill: #1f77b4;">Afghanistan</text> ``` and all I want to do is to grab the "Afghanistan" text from that on a click event. d3.select(this)... Thanks!

Original source