I am trying to make the various sentences in a document, with the class "line", grow increasingly opaque. When they get to be totally opaque, I want a sound to play and the opacity to begin reducing. For now I am trying to simply set the opacity to -.5 .
function increaseOpacity() {
var lines = document.querySelectorAll(".line");
var increment = .01;
for (var i = 0; i < lines.length; i++ ) {
var element = lines[i];
var x = element.getAttribute("opacity");
if (x <= 1) {
x += increment;
}
else if (x >= 1) {
x = -.5;
var audio = new Audio('sound/hush002.mp3');
audio.play();
}
}
}
setInterval(increaseOpacity, 500);