Below is my JavaScript code that switches between 2 words every 2.5 seconds. I want to enhance the transition between the words by adding a fading effect using jQuery. How can I integrate this into the recursive function? Any suggestions?
var text = ["first", "second"];
var counter = 0;
var elem = document.getElementById("changeText");
setInterval(change, 2500);
function change() {
elem.innerHTML = text[counter];
counter++;
if (counter >= text.length) {
counter = 0;
}
}
.banner-right h2 {
font-size: 50px;
font-weight: 300;
color: #ffffff;
margin: 15px 0 45px 0;
}
<h2 id="changeText">Data Scientist</h2>