简体   繁体   中英

How to select an element insert using insertAdjacentHTML?

Using native Javascript. After adding a new element via insertAdjacentHTML, I want to select one of that elements. How do I get that without having to search through the DOM?

You can't.

You've generated the element in a way that doesn't leave you with a reference to it. The DOM is the only place it exists.

Searching through the DOM is the only way to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM