这是我的代码。
var cSharpButtons = document.getElementsByClassName("csharpbutton");
var jSButtons = document.getElementsByClassName("jsbutton");
var cSharp = document.getElementsByClassName("csharp");
var jS = document.getElementsByClassName("js");
function switchToCSharp()
{
for (i = 0; i < cSharpButtons.length; i++) //change button colors
{
cSharpButtons[i].style.backgroundColor = "#00AEEF";
}
for (i = 0; i < jSButtons.length; i++)
{
jSButtons[i].style.backgroundColor = "lightgrey";
}
for (i = 0; i < cSharp.length; i++) //change code
{
cSharp[i].style.display = "inline";
}
for (i = 0; i < jS.length; i++)
{
jS[i].style.display = "none";
}
}
function switchToJS()
{
for (i = 0; i < jSButtons.length; i++) //change button colors
{
jSButtons[i].style.backgroundColor = "#00AEEF";
}
for (i = 0; i < cSharpButtons.length; i++)
{
cSharpButtons[i].style.backgroundColor = "lightgrey";
}
for (i = 0; i < cSharp.length; i++) //change code
{
cSharp[i].style.display = "none";
}
for (i = 0; i < jS.length; i++)
{
jS[i].style.display = "inline";
}
}
GoDaddy 表示许可没问题。在我的桌面上就像一个魅力,他们说我的代码一定有问题。他们说这可能是一种过时的编码方式。
当您按下按钮时没有任何反应,要亲自尝试一下,请访问 http://spacehelmetstudios.com/tutorials/unity2d/directionalgravity2d/directionalgravity2d.html并尝试将其从 C# 更改为 JS。
我不会撒谎,我对服务器端的事情不太了解。
有什么想法吗?谢谢。
最佳答案
我知道这不是答案,但在开发人员控制台中我没有看到任何下载的 JS 文件,并且收到控制台错误,指出您的函数未定义。也许您忘记将 JS 文件添加到 <head>
中标签?
关于Javascript 无法在 GoDaddy 托管上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43285256/