[英]How to select an element insert using insertAdjacentHTML?
Using native Javascript.使用原生 Javascript。 After adding a new element via insertAdjacentHTML, I want to select one of that elements.通过 insertAdjacentHTML 添加新元素后,我想 select 其中一个元素。 How do I get that without having to search through the DOM?我如何在不必搜索 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. DOM 是它唯一存在的地方。
Searching through the DOM is the only way to do it.搜索 DOM 是唯一的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.