javascript - 如何使用javascript隐藏元素

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

最佳答案

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

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

如果有多个则:

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

或者如果你想使用 jQuery:

$("tspan").hide();

关于javascript - 如何使用javascript隐藏元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32336063/

相关文章:

javascript - 使用 JavaScript 和/或 C# (Unity3D) 从 PHP 脚本加载一些变量

javascript - 基于选择下拉菜单的 jQuery 显示/隐藏未按预期工作

Jquery数据表-分页DOM

javascript - 如何在 Highcharts 的图例中显示情节线?

javascript - 如何防止 Highcharts 中出现气泡?

javascript - 呈现到具有多种图表类型和选项的同一个容器

javascript - 当x轴和数据有时间范围时如何将数据放在折线图上

javascript - 检测自动网络请求

javascript - 我希望能够在不禁用手机滚动的情况下跟踪滑动

Javascript console.log 不读取数组未定义