How can I change a word every 2-3 seconds using jQuery?
For example:
I have this:
<div>
<span>This is so</span>
<span>awesome</span>
</div>
... and I want the awesome to change into cool,fantastic,incredible and keep cycling with loop using fadeOut/fadeIn effect maybe?
Is it possible?
Thanks alot
Apply an ID to the span and change its contents using
.text()
or.html()
live demo here
JQuery: jsfiddle
Pure JavaScript: codePen
Pure CSS: codePen
:before
pseudo withcontent
with your first wordcontent
)Give your span an id, and change
changerificwordspanid
to the id of the span.JSFiddle Example here
You can easily do this using
setInterval
and few lines of code.Working demo
This should work. First, add an id to the span that you want to rotate the text on. E.g.,
And in your JavaScript:
You can see this in action here: http://jsfiddle.net/DMeEk/