It looks like you need to smooth out the "f" in the property webkitFilter:
document.images[h].style.webkitFilter = "grayscale(1)";
document.images[h].style.filter = "grayscale(1)";
Chrome still requires a prefix -webkitfor the filterproperty , but it should have already worked in Firefox.
If you want to iterate over the elements and remove the filter from the current element and add it back to the previous element, you can use the following:
i % images.length - , reset 0, i .
(curr - 1 < 0 ? images.length : curr) - 1 - , , 1 1 , -1.
, // , , , :
var images = document.querySelectorAll('img'),
i = 0;
function removeGreyscale() {
var curr = i % images.length,
prev = (curr - 1 < 0 ? images.length : curr) - 1;
images[curr].style.webkitFilter = "grayscale(0)";
images[curr].style.filter = "grayscale(0)";
images[prev].style.webkitFilter = "grayscale(1)";
images[prev].style.filter = "grayscale(1)";
i++;
}
setInterval(removeGreyscale, 1000);
img {
-webkit-filter: grayscale(1);
filter: grayscale(1);
}
<img src="//placehold.it/200/f00" />
<img src="//placehold.it/200/0f0" />
<img src="//placehold.it/200/00f" />
Hide result