如何使用javascript隐藏元素

如何使用javascript隐藏元素,javascript,jquery,highcharts,Javascript,Jquery,Highcharts,如何在图表上隐藏日期 <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

如何在图表上隐藏日期

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

使用Highstock 1.3.7创建
7/9/15

如果只有一个,那么此代码应该可以工作:

document.querySelector("tspan").style.display = "none";
如果有多个,则:

[].forEach.call(document.querySelectorAll("tspan"), function(item) {
  item.style.display = "none";
});
或者,如果要使用jQuery:

$("tspan").hide();

与此没有太大区别:我尝试了很多选项,但都不起作用,请帮助“我尝试了很多选项”。让我们看看您尝试了什么好吗?
$('tspan').remove()
要完全删除它并清空
tspan
只需使用
$('tspan').html(“”)
为什么不能为点设置空值?然后点将为空;)有多个TSPAN。我没有复制整个代码,我尝试了这个方法,但没有成功$('div.highcharts-container>svg>text').find('tspan').html(“”);Dave,那么我可以做这个$('div.highcharts-container>svg>text').forEach.call(document.queryselectoral(“tspan”),function(item){item.style.display=“none”;});如果您使用的是jQuery,请使用我答案中的最后一行——不要过于复杂。