element.firstChild is returning '<TextNode …' instead of an Object in FF

后端 未结 6 2029
傲寒
傲寒 2020-11-29 07:50

I wrote a tab system using some very basic Javascript and it runs like a champ in IE 8 but, in FireFox 3 I am coming up short. The pertitent HTML is as follows:

<         


        
6条回答
  •  感情败类
    2020-11-29 08:20

    Use element.querySelector("*") to get the first child Element.

    Demo:

    var container = document.getElementById("container")
    
    console.log(container.querySelector("*")) // 
    This is a test
    console.log(container.firstChild) // #text console.log(container.childNodes[0]) // #text
    This is a test

提交回复
热议问题