gpt4 book ai didi

Javascript 选择要调用的脚本

转载 作者:行者123 更新时间:2023-12-02 17:32:59 24 4
gpt4 key购买 nike

<!DOCTYPE html>
<html>
<head>
<style>
#container {
width: 320px;
height: 400px;
border: 1px solid red;

}
#top {
width: 320px;
height: 80px;
border: 1px solid blue;

}

</style>
<script>
var type;
function one(){
type = One.js
}
function two(){
type = Two.js
}


</script>

</head>
<body>

<div id="top">
<button onclick="one()">One</button>
<button onclick="two()">Two</button>

<button onclick="start()">Start</button>
<button onclick="stop()">Stop</button>
<button onclick="pause()">Pause</button>

</div>


<div style="position: relative;" id="container">

<canvas id="myCanvas" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>
<canvas id="trail" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>

<canvas id="plane" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>
<canvas id="buildings" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>
<canvas id="cloud" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>

<canvas id="buildings2" width="320" height="400"
style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>

<canvas id="canvas2" width="100" height="100"
style="position: absolute; left: 0; top: 0; z-index: 1;"></canvas>
</div>



<script type="text/javascript" src=type> </script>

</body>
</html>

是否可以在激活脚本之前有一个按钮来定义正在播放的脚本。因此有一个下拉框可以编辑正在激活的脚本。我不知道该怎么做。谢谢:)

最佳答案

您可以将一个值传递给您的函数来选择您要使用的值。例如:

function select(which){
switch(which)
{
case 1:
// execute One.js
break;
case 2:
// execute Two.js
break;
default:
//
}

}

关于Javascript 选择要调用的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22889420/

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