Home > Mobile >  How to select element from HTMLElement
How to select element from HTMLElement

Time:01-05

I am trying to select elements from the HTML Element. But not working. How to do it? I have used query selector but it is not working.

HTML: Getting this from console.log(drop);

<div >
<dropdown-part>
 <select>
 <option>2</option>
 </select>
</dropdown-part>
</div>

TypeScript:

let dropcover = this.shadowRoot.querySelector('.container') as HTMLElement;
console.log(drop);

let dropDown = dropcover.querySelector('dropdown-part');
console.log(dropDown); // Getting null

CodePudding user response:

Fix code as blew :D

<dropdown-part >
 <select>
 <option>2</option>
 </select>
</dropdown-part>

CodePudding user response:

If you want to get shadow dom, you sholud watch this shadow dom

  •  Tags:  
  • Related