Accepted answer

Using D3, you can select one rectangle on click and get the title this way (regarding the specific SVG structure you provide in your question):

d3.selectAll("rect").on("click", function(){
  var title = this.parentNode.parentNode.getElementsByTagName("title")[0].childNodes[0];

The value of the tag title is stored in var title. Here is a fiddle:


Short and sweet

d3.selectAll('rect').on('click', function() {
  var title =;

if title element is before the rect element then use

var title =;

Use d3 selectors and text function to get the value you want

Working Fiddle