JavaScript 函数定义不正确

JavaScript function not defining properly

本文关键字:不正确 定义 函数 JavaScript      更新时间:2023-09-26

我到处寻找解决方案,但一无所获。出于某种原因,当我尝试调用一个函数时,它说它是未定义的。

function removeBusiness(num){ 
    companies.splice(num, 1); //Removes a company from the companies array.
    tabCreate(tabsbody[0]); //Reloads the current tab that you are in.
};
var tabsbody = ["tab_name", "element", 0/*is active*/];
var tabs;
function TabCreate(tab){
    switch(tab){
        case "contract":
            if( tabsbody[2] == 1 ){tabsbody[1].remove(); //Removes old tab page and builds the requested one.
                tabs.style.backgroundColor = "#648a64";
            }else{ tabsbody[2] = 1;};
            if( tabsbody != "contract"){
                tabsbody[0] = "contract";
                var submain = document.createElement("div");
                    submain.style.height = "70vh";
                    submain.style.width = "98%";
                    submain.style.margin = "auto";
                    tabsbody[1] = submain;
                    document.getElementById("main").appendChild(submain);
                tabs = document.getElementById("contractlisten");
            };
        break;
    };
};
removeBusiness(0);

这是我的一些代码,但我删除了很多情况以使其更易于阅读。我在页面加载后调用删除业务加上 3 秒。有什么帮助吗?

调用"TabCreate"函数时使用大写字母"T"。

更新

Javascript 区分大小写,http://en.wikipedia.org/wiki/JavaScript_syntax#Case_sensitivity。