Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hey there and compliments of the season. I'm trying to pop strings off an array into an element with id "firstPara" but only on scroll. I also want the strings to be popped on interval. Here's my code

JavaScript
var firstString = ["This ", "is ", " me."];
			var firstPara = document.querySelector("#firstPara");
			var distanceSoFar = (document.body.scrollTop);
			
			window.addEventListener("scroll", function (){
			setInterval(slideIn, 450);
			});
			
			function slideIn(){
			if (distanceSoFar > "130") {
			for (var i = 0; i < firstString.length; i++) {
			var stringOut = firstString.shift();
			firstPara.innerHTML += stringOut;
			}
			}};

It doesn't log any errors in the console and does not pop anything either.
Posted
Updated 23-Dec-15 18:29pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Dec-15 0:40am    
Not clear.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900