title: Remove d3 tooltip onclick
body: <p>I am using d3 charts to show a scatter plot. I am showing tooltip on click. I have to remove the tooltip if I click anywhere on the page. How should I remove the tooltip?</p>
  
  <pre><code>var svg = d3.select("#scatter_plot")
    .append("svg")
    .attr("width", chart_width)
    .attr("height", chart_height)
  // create x_scale
  
  var div = d3.select("body").append("div")
    .attr("class", "tooltip1 scatter_tooltip")
    .style("opacity", 0);
  // add circles
  svg.selectAll("circle")
    .data(data)
    .enter()
    .append("circle")
    .attr("cx", function (d) {
      return x_scale(d.Staff_count)
    })
    .attr("cy", function (d) {
      return y_scale(d.Outlets)
    })
    .attr("r", function (d) {
      return a_scale(d.Total_Sales)
    })
    .attr("fill", function (d) { return scatter_color(d.Total_Sales) })
    .on("click", function (d) {
      var div_html = "&lt;div class='d-flex justify-content-center m-2'&gt;&lt;div class='font-weight-bolder pr-2'&gt;"
      var div_end =  "&lt;hr&gt;" + "&lt;/div&gt;&lt;/div&gt;" + div_html + "Total Sales" + ": " + d.Total_Sales + "&lt;/div&gt;&lt;/div&gt;" + "&lt;/div&gt;&lt;/div&gt;"+ div_html + "Outlets" + ": " + d.Outlets + "&lt;/div&gt;&lt;/div&gt;" + "&lt;/div&gt;&lt;/div&gt;"+ div_html + "Staff Count" + ": " + d.Staff_count
      $(".tooltip1").show()
      div.transition()
        .duration(100)
        .style("opacity", .9);
      if (state_ == 'India') {
        div.html(div_html + d.State + div_end + "&lt;/div&gt;&lt;/div&gt;" + "&lt;button class = 'myBtn btn btn-primary' id='" + d.State + "'&gt;District Details &gt;&gt;&lt;/button&gt;")
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY - 28) + "px");
      } else {
        div.html(div_html + d.District + div_end)
          .style("left", (d3.event.pageX) + "px")
          .style("top", (d3.event.pageY - 28) + "px");
      }
      tooltip_load()
      toolTipIsVisible()
    })
  </code></pre>
  
  <p>It would be helpful if anyone gives some idea of how to work this out. </p>