How to get all childNodes in JS including all the 'grandchildren'?

前端 未结 3 809
南旧
南旧 2021-02-04 23:14

I want to scan a div for all childNodes including the ones that are nestled within other elements. Right now I have this:

var t = document.getElementById(\'DivId         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 00:04

    This is the fastest and simplest way, and it works on all browsers:

    myDiv.getElementsByTagName("*")
    

提交回复
热议问题