detecting a span while looping using jquery/js?
<p>I wanted to detect a span element while looping through a div element i.e.</p>

<pre><code>&lt;div class="example"&gt;
    These are some &lt;span id ="special" class="anime"&gt;special&lt;/span&gt; words 
   that should be faded in one after the other.
&lt;/div&gt;
</code></pre>

<p>using javascript i split the words and fade them in one by one i.e.</p>

<p>JS:</p>

<pre><code> function doSomething(spanID) {
     alert(spanID);
     }

 var $el = $(".example:first"), text = $.trim($el.text()),
        words = text.split(" "), html = "";

    for (var i = 0; i &lt; words.length; i++) {
        html += "&lt;span&gt;" + words[i] + ((i+1) === words.length ? "" : " ") + "&lt;/span&gt;";
    };
    $el.html(html).children().hide().each(function(i){
      // if special span is detected
      // get the span id pass it to doSomething function 
      $(this).delay(i*200).fadeIn(700);
    });
    $el.find("span").promise().done(function(){
        $el.text(function(i, text){
           return $.trim(text);
        });            
    });
</code></pre>

<blockquote>
  <p>working example is here: <a href="http://jsfiddle.net/6czap/5/" rel="nofollow">http://jsfiddle.net/6czap/5/</a></p>
</blockquote>

<p>everything works, it just that i need to detect any special spans so i can do something with them, and then the for loop should carry on doing what it deos. thanks</p>
