GetElementById from within Shadow DOM

后端 未结 1 660
野趣味
野趣味 2021-01-11 18:43

I have a custom-element with shadow DOM, which listens to attribute target change.
target is supposed to be the ID of the element which my comp

相关标签:
1条回答
  • 2021-01-11 19:22

    You just have to call Shadow​Root.

    this.shadowRoot.getElementById('target') should work.

    Here's an example, the get syntax will bind an object property to a function.

    get target() {
        return this.shadowRoot.getElementById('target');
    }
    
    0 讨论(0)
提交回复
热议问题