当我单击网页中的图像之一时,我有三个图像标签,我不想它消失,但是当我双击时,我希望它消失。
let img = document.querySelectorAll("img");
console.log(img)
let c = Array.from(img);
console.log(c);
c.forEach(function(imgs) {
imgs.addEventListener("click", function(e) {
let d = imgs;
d.addEventListener("dblclick", function(v) {
console.log(img)
// I want this eventlistener to make it disapear
document.querySelectorAll("image").innerHTML = "";
})
})
})
答案 0 :(得分:0)
再次阅读您的帖子后,我对答案做了一些更改!
array([1,
array([12557217, 5572869, 13415223, 2532000, 14609022, 9830632,
9800679, 7504595, 10752682])], dtype=object)
const imgs=document.querySelectorAll("img");
imgs.forEach(function(img){
img.addEventListener("dblclick", function(){
this.remove();
});
});
.box {
width: 220px;
padding: 20px;
background-color: #eee;
}
答案 1 :(得分:0)
这有效。以上答案也适用。
let img = document.querySelectorAll("img");
console.log(img)
let c = Array.from(img);
console.log(c);
c.forEach(function(imgs) {
imgs.addEventListener("dblclick", function(e) {
imgs.style.display = "none";
})
})
<img src="https://via.placeholder.com/200x200" width=150 height=150>