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

后端 未结 6 2026
傲寒
傲寒 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:14

    With a an eye also on efficiency, this function returns firstChild element node of el

    function firstChildElement(el)
    {
        el = el.firstChild;
        while (el && el.nodeType !== 1)
           el = el.nextSibling;
        return el;
    }
    

提交回复
热议问题