我想用jQuery的动画从HTML元素中采取的文本字符串:使用jquery动画HTML元素文本的每个字符?
<h1>Animate</h1>
的jQuery的一部分:
$(document).ready(function() {
$("h1").animate({ fontSize: "90px" }, 1500)
.animate({ fontSize: "50px" }, 1500);
});
这个动画整个H1文本值,但是我想动画h1文本中的每个字符。
第二jquery的部分:
$(document).ready(function() {
var animateChar = $("h1").text();
for(i=0; i<animateChar.length; i++) {
//alert(i + ': ' + animateChar.charAt(i));
// for every animateChar.charAt[i] want to run this
//jquery animation.
//$("h1").animate({ fontSize: "90px" }, 1500)
//.animate({ fontSize: "50px" }, 1500);
}
});
这是比特,其中即时卡住。感谢
您必须将每个字符包裹在一个范围内 - 文本节点是不可分割的。 – Alnitak 2012-07-23 15:07:44
我不确定如果没有将每个字符分隔到另一个容器中,例如'',都是可能的。我想你可以先做,然后通过它们循环。 – Thor84no 2012-07-23 15:07:46
你是多么有趣的想法!让我试试看!!谢谢 – unknown 2012-07-23 15:09:41