assuming I have a code that randomly selects an element in an array just as below, how will I make the next element fadeIn;
var textHolder = document.getElementById("text");
var button = document.getElementById("btn");
var arrayText = ["the King", "love don't cost a thing", "the programming guru", "a"];
<h2 id="text">change me randomly</h2>
<button id="btn">new random</button>
this is the function that does the random text generator
var randomText = function(){
var randomNumber = Math.floor(Math.random()*arrayText.length);
textHolder.innerHTML = arrayText[randomNumber];
};
i itry to add fadin method here but the code stop work but when i remove the fade method it start working again, please what am i doing wrong.
button.addEventListener("click", function(){
textHolder.fadeOut();
randomText();
textHolder.fadeIn();
});