javascript - 无法使用 javascript 更改图像 src
问题描述
当我单击 2 img not identique 我希望它更改为另一个 img 但它无法工作
function changeImage1()
{
var img1 =document.getElementById("image_change");
var img2 =document.getElementById("image_change1");
var img3 =document.getElementById("image_change2");
if(img1.src===img2.src)
{
setTimeout( function ( ) { alert( "identique" ); }, 1000 );
}
else if(img1.src === img3.src)
{
document.getElementById("image_change").src="img111.jpg";
document.getElementById("image_change2").src="img111.jpg";
setTimeout(changeImage1, 1000);
}
}
<table>
<tr>
<td >
<img src="img111.jpg" alt="img1"
width="100" height="100"
onClick="changeImage(this.id); changeImage1(this.id)"
id="image_change">
</td>
<td >
<img src="img111.jpg" alt="img3"
width="100" height="100"
onClick="changeImage(this.id); changeImage1(this.id)"
id="image_change2">
</td>
<td>
<img src="img111.jpg" alt="img1"
width="100" height="100"
onClick="changeImage(this.id); changeImage1(this.id)"
id="image_change1">
</td>
</tr>
<table>
解决方案
推荐阅读
- wso2 - 如何为 CustomUserStoreManager 创建域?
- java - Android Job Scheduler 应用程序关闭后作业不执行
- php - 使用 certbot 安装 ssl 证书时如何解决未经授权的错误?
- html - 树形图 - 将最后一个孩子移动到 html/css 中的一级
- java - 为什么我在使用休眠时总是遇到同样的错误:ORA-00979:不是 GROUP BY 表达式?
- javascript - 传递给其他刀片后,我的 id 值未从第一个数字中读取数字 0
- css - 如何创建自定义样式的键盘快捷键
- javascript - 通过在 Elasticsearch 中优先考虑索引来查询多个索引?
- web-services - 如何才能实现松耦合“面向服务的架构”(SOA)?解释使用合适的解决方案
- javascript - 是否可以从 Redux 存储中检索特定评论评论的状态