How to find with javascript if element exists in DOM or it's virtual (has been just created by createElement)

后端 未结 6 1520
庸人自扰
庸人自扰 2021-01-12 04:36

I\'m looking for a way to find if element referenced in javascript has been inserted in the document.

Lets illustrate a case with following code:

v         


        
6条回答
  •  心在旅途
    2021-01-12 04:59

    function isInDocument(query){
      return document.querySelectorAll(query).length != 0;
    }
    // isInDocument("#elemid") 
    

提交回复
热议问题