Nisha Nethani
Nisha Nethani

Reputation: 109

How to hide an element using javascript

this is the graph and i need to hide the dates

how can i hide the date on the graph

<div class="highcharts-container" id="highcharts-6">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1330"   height="532"><desc>Created with Highstock 1.3.7</desc><defs><clipPath id="highcharts-7"><rect fill="none" x="0" y="0" width="1239" height="290"></rect></clipPath></defs>
<path fill="none" d="M 71 45 L 71 335 180 335 180 45" zIndex="5"></path>
<text x="126" y="29" transform="translate(0,0)" visibility="visible">
<tspan x="126">7/9/15</tspan></text></svg></div>

Upvotes: 1

Views: 120

Answers (1)

Dave
Dave

Reputation: 10924

If there's just one, then this code should work:

document.querySelector("tspan").style.display = "none";

If there are multiple then:

[].forEach.call(document.querySelectorAll("tspan"), function(item) {
  item.style.display = "none";
});

Or if you want to use jQuery:

$("tspan").hide();

Upvotes: 2

Related Questions