Is it possible to use querySelector() on a dynamic

2019-09-17 19:56发布

I'm using appendHtml() in a loop to dynamically add li elements (with unique IDs in the string) to a ul. When I need to access these dynamically created li elements by their IDs to, for example, create nested lists, querySelector() returns null. If I should be able to do this, then there could very well be bugs in my code. But I want to make sure this is the case.

1条回答
叼着烟拽天下
2楼-- · 2019-09-17 20:33

It doesn't matter how elements are added, if the are part of the DOM querySelector can find them.

查看更多
登录 后发表回答