Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create an <code>array</code> of words then loop through the array index with <code>setInterval</code> and use jQuery <code>slideUp</code> - <code>slideDown</code> for the animation.</p> <p>html:</p> <pre><code>&lt;p&gt;Build and cultivate your own community of&lt;/p&gt; &lt;div id="word"&gt;customers&lt;/div&gt; </code></pre> <p>script:</p> <pre><code>var words = ['followers', 'fans', 'members', 'customers']; var index = 0;//start with 0, first array index is 0 var $word = $('#word'); setInterval(function () { if (index == words.length) { //if current index is equal to the arrays length reset it to 0 index = 0; } //slideUp to hide $word.slideUp(500, function () { //on animation complete hidden change the text then slideDown to show $word.text(words[index]).slideDown(500); /* It's always a good practice to separate increment/decrement in a single line, as it might confuse some(especially new) programmers */ index++; }); }, 2000); </code></pre> <p>See this <a href="http://jsfiddle.net/mark_s/Dsas8/1/" rel="nofollow"><strong>jsfiddle</strong></a>.</p> <p>You can use <code>&lt;span&gt;</code> but it will create a different effect because <code>&lt;span&gt;</code> is an <strong>inline element</strong> (check this <a href="http://jsfiddle.net/mark_s/Dsas8/2/" rel="nofollow">jsfiddle</a>). You need to set it to <code>display:block</code> to achieve the desired effects - <a href="http://jsfiddle.net/mark_s/Dsas8/3/" rel="nofollow"><strong>jsfiddle demo</strong></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload