gpt4 book ai didi

Javascript 检查数字是否=变量

转载 作者:行者123 更新时间:2023-11-28 13:23:02 25 4
gpt4 key购买 nike

var Period =1;

if(Period==1){
document.getElementById("Main").style.backgroundImage = "url('Main_Background_Grass_1.png')";
}

由于某种原因,这不起作用。图像位置是正确的,但我确定有问题。

我对 javascript 还很陌生

这里有更多代码

<script type="text/javascript">

var Knowledge = 0;
var Period =1;

if(Period==1){
document.getElementById("Main").style.backgroundImage = "url('Main_Background_Grass_1.png')";
}

</script>

<div id="Main">

<div id="Toolbar">
Oh noes! Something Went Wrong
</div>
</div>

图像根本不会显示

最佳答案

调用函数时未找到该元素,请将 JavaScript 放在结束正文标记之前

<div id="Main">

<div id="Toolbar">
Oh noes! Something Went Wrong
</div>
</div>

<script type="text/javascript">

var Knowledge = 0;
var Period =1;

if(Period==1){
document.getElementById("Main").style.backgroundImage = "url('Main_Background_Grass_1.png')";
}

</script>

关于Javascript 检查数字是否=变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31594678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com