如何使用javascript隐藏元素

时间:2015-09-01 15:55:39

标签: javascript jquery highcharts

this is the graph and i need to hide the dates

如何隐藏图表上的日期

<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>

1 个答案:

答案 0 :(得分:2)

如果只有一个,则此代码应该有效:

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

如果有多个则:

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

或者如果你想使用jQuery:

$("tspan").hide();