$el.html から特定の子要素を選択したいのですが、2 種類の子要素があり、1 つは<span>....</span>
で、もう 1 つはスパン クラス<span class = "special">..</span>
です。
var orig = $(".example").html()
,$el = $(".example")
,text = $.trim($el.text())
,words = text.split(" ")
,html = "";
for (var i = 0; i < words.length; i++) {
if (words[i] === "senior")
html += "<span class='special'>" + words[i] + ((i+1) === words.length ? "" : " ") + "</span>";
else
html += "<span>" + words[i] + ((i+1) === words.length ? "" : " ") + "</span>";
};
$el.html(html).children().hide().each(function(i){
// if $('span.special')
$(this).delay(i*200).fadeIn(700);
// else (normal span)
$(this).delay(i*600).fadeIn(900);
}).promise().done(function(){
$('.example:first').html(orig)
})
「各」呼び出し内のクラスがある場合とない場合のスパンの違いをどのように見分けることができますか?
実際のデモはこちらです: http://jsfiddle.net/6czap/15/