I am wondering why the opacity for the element is not temporary reduced when the appropriate button is pressed. Thanks for your help.
function sleep(miliseconds) {
var currentTime = new Date().getTime();
while (currentTime + miliseconds >= new Date().getTime()) {}
}
function temporarHide(ev) {
document.getElementById(ev).style.opacity = '0.16';
sleep(1500);
document.getElementById(ev).style.opacity = '1';
}
<div id="epicenter">
<img src="https://via.placeholder.com/45/000" alt="Schwarz" id="black">
<img src="https://via.placeholder.com/45/00f" alt="Blau" id="blue">
<img src="https://via.placeholder.com/45/0f0" alt="Grün" id="green">
<img src="https://via.placeholder.com/45/ddd" alt="Grau" id="grey">
<img src="https://via.placeholder.com/45/a0d" alt="Lila" id="lila">
<img src="https://via.placeholder.com/45/e73" alt="Orange" id="orange">
<img src="https://via.placeholder.com/45/f00" alt="Rot" id="red">
<img src="https://via.placeholder.com/45/ff0" alt="Gelb" id="yellow">
<img src="https://via.placeholder.com/45/fcc" alt="Rosa" id="rosa">
</div>
<button onclick="temporarHide('black')">black</button>
<button onclick="temporarHide('blue')">blue</button>
<button onclick="temporarHide('green')">green</button>
<button onclick="temporarHide('grey')">grey</button>
<button onclick="temporarHide('lila')">lila</button>
<button onclick="temporarHide('orange')">orange</button>
<button onclick="temporarHide('red')">red</button>
<button onclick="temporarHide('yellow')">yellow</button>
<button onclick="temporarHide('rosa')">rosa</button>