我想以这样的方式实现,当我们单击图像时,所选图像应出现在前面,其余图像应隐藏在所选图像后面。
我已经得到了使用jquery实现类似功能的代码引用。
Click on image to move to front?
请告诉我如何使用 Angular 或使用纯 JavaScript 来完成此操作?
最佳答案
使用纯 JavaScript:
let images = document.getElementsByClassName('myclass');
Array.prototype.forEach.call(images, (img) => img.addEventListener('click', function() {
Array.prototype.forEach.call(images, (img) => img.style.zIndex = 0);
this.style.zIndex = 100;
}));
关于javascript - 如何使用 angular1 让图像在点击时显示在前面/后面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45732315/