I am trying to fade in the elements wrapped in span tags randomly. There are a few examples on stackoverflow, but I cannot get them them to work in my code.
Also.. Is there a more elegant way of doing this than wrapping every single word in span tags?
I am trying to turn akll the spans into an array, then select an element in that array at random, and fade it in via changing the opacity of that element, then remove it from the array Here is a jsfiddle of myy attempt..
https://jsfiddle.net/jnghna9s/2/
My script.js:
$(document).ready(function() {
$("#contact").click(function() {
var spans = $("#changingP span").get();
for(var i =0; i < spans.length; i++) {
var index = Math.floor(Math.random() * spans.length);
$(spans[index]).fadeTo(200, 1, function() {
spans.splice(index,i);
}
})
});
});