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

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

    I would recommend anyone trying to work with the DOM in javascript to use a library like jquery. It will make your life much easier.

    You could then rewrite the JS function as fallows:

    function processTabs(TabContainer, PageContainer, Index) {
        var tabContainer = document.getElementById(TabContainer);
    
        // jquery used to find all the 
  • elements var tabs = $(tabContainer).filter('li'); // use the jquery get( index ) function to retrieve the first tab var tab = tabs.get(0); var i = 0; .... more code }
提交回复
热议问题