gpt4 book ai didi

javascript - 设置按钮以更改图像Javascript

转载 作者:太空宇宙 更新时间:2023-11-04 16:21:55 25 4
gpt4 key购买 nike

它应该是直截了当的,但我无法获得单击按钮时更改图像的功能。请任何人发现以下代码有什么问题。提前致谢。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>BlankCordovaApp4</title>

<!-- BlankCordovaApp4 references -->
<link href="css/index.css" rel="stylesheet" />
</head>
<body>
<p>Greeting!</p>

<img id="demo" src="images/hello.jpg" width="180" height="123">

<button id="Btn" type="button" onclick="changeImage();">Click Me</button>

<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>

<script src="scripts/platformOverrides.js"></script>

<script src="scripts/index.js"></script>


<script>

function changeImage() {

document.getelementbyid("demo").src = "images/bye.jpg";
};

</script>

</body>
</html>

最佳答案

应该是:

document.getElementById("demo").src = "images/bye.jpg";

javascript 中的大小写:getelementbyidgetElementById 不同。

关于javascript - 设置按钮以更改图像Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28660451/

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