相关疑难解决方法(0)

如何从文档中选择打开的 Shadow DOM 中的元素?

假设我的文档中有一个如下所示的 DOM:

<body>
  <div id="outer">
    <custom-web-component>
      #shadow-root (open)
        <div id="inner">Select Me</div>
    </custom-web-component>
  </div>
</body>
Run Code Online (Sandbox Code Playgroud)

是否可以使用单个querySelector参数来选择影子根内的内部 div document?如果是的话,它是如何构建的?

例如,类似的东西document.querySelector('custom-web-component > #inner')

html css shadow-dom

7
推荐指数
2
解决办法
8770
查看次数

标签 统计

css ×1

html ×1

shadow-dom ×1