Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML和JS,在divs中隐藏tome表_Javascript_Html - Fatal编程技术网

Javascript HTML和JS,在divs中隐藏tome表

Javascript HTML和JS,在divs中隐藏tome表,javascript,html,Javascript,Html,我有这样一个代码: <div id="mapLegendInside"> <div> <table> // code </table> <div> <table class="esriLegendLayerLabel"> // code </table> <table c

我有这样一个代码:

<div id="mapLegendInside">
   <div>
      <table>
         // code
      </table>
      <div>
         <table class="esriLegendLayerLabel">
            // code
         </table>
         <table class="esriLegendLayer"> <--- I need to hide this table
            // code
         </table>
         <table class="esriLegendLayer">
            // code
         </table>
      </div>
   </div>
</div>
我有一些html代码如下:

<div id="mapLegendInside">
   <div>
      <table>
         // code
      </table>
      <div>
         <table class="esriLegendLayerLabel">
            // code
         </table>
         <table class="esriLegendLayer"> <--- I need to hide this table
            // code
         </table>
         <table class="esriLegendLayer">
            // code
         </table>
      </div>
   </div>
</div>
我将隐藏整个主div,但是,我怎么能只选择我所指的表呢?请注意,我不能将类或id添加到表或div中,这段代码是由外部javascript库生成的,我只需要在主div的div中的第二个元素div中选择第二个表,哈哈

下面是一个可以使用的代码:

你可以举个例子

var layers=document.querySelectorAll.esriLegendLayer

图层将是一个元素数组,该数组具有esriLegendLayer类,您可以根据需要更改传递的选择器,使其或多或少具有特定性

仅更改您可以使用的第一个


document.querySelector.esriegendlayer.style.display='none'

您可以使用document.querySelector或querySelectorAll

//您可以使用`document.querySelector` document.querySelector'mapLegendInside table.esriLegendLayer'.style.display='none'; //或-使用'queryselectoral'` 设置超时=> document.querySelectorAll'mapLegendInside table.esriLegendLayer'[0].style.display='block',1000; 密码 代码-table.esriLegendLayerLabel 我需要隐藏的表的代码 代码-table.esriLegendLayer 您需要保持表的结构。将tr和td添加到表中,下面的代码将起作用

表格示例

<table>
  <tr>
    <td>code</td>
  </tr>
</table>

document.querySelectorAllmapLegendInside表[2]。style.display=none

document.querySelector.esriLegendLayer.style.display='none'@pmirnd不能将文本直接放入表中。它正在工作,请参见此处:不确定您的意思,在该页面上运行document.querySelector.esriLegendLayer,您将看到​​我认为你应该好好学习英语。你的答案比@Alona Vereshaka的答案信息要少。检查她的答案。你为什么要考虑参加esriLegendLayer课程?若选择表格是为了特殊用途,那个么我想你们的答案是错误的。你可以浏览答案,并检查最佳答案。这也是为即将到来的访客准备的。@pmirnd,考虑到整个问题的细节,这个答案是最好的。如果没有,我想你需要更新你的问题。谢谢