gpt4 book ai didi

javascript - 使用 javascript 更改图像源 - 有什么问题吗?

转载 作者:行者123 更新时间:2023-11-28 20:30:03 24 4
gpt4 key购买 nike

<IMG onmouseover="document.swap2.src='http://www.grlf.com/pics/png';" id="brewmp" alt=Brew src=changeOSImage() width=26 height=24>


function changeOSImage() {
var mp_os = "x";

if (mp_os) == "Brew MP") {
document.getElementById("brewmp").src = "http://www.greengo-cellular.com/ebay_files/images/features_n_02.png";
} else {
document.getElementById("brewmp").src = "http://www.greengo-cellular.com/ebay_files/images/features_02.png";
}
};

由于某种原因,url 没有更改 url,而是显示了其中的函数名称(因此无处可去)。我做错了什么?

最佳答案

您不能在图像的 src 属性中指定函数。

尝试将 changeOSImage() 函数放在文档的 onload 事件中,或从其他函数调用它。

关于javascript - 使用 javascript 更改图像源 - 有什么问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16598212/

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