首页 > PHP资讯 > HTML5培训技术 > 不错的文字特效,逐字变色效果_典型特效

不错的文字特效,逐字变色效果_典型特效

HTML5培训技术
<script language="JavaScript">
text = "www.jb51.net";
color1 = "green";
color2 = "red";
speed = 200;
i = 0;
if (navigator.appName == "Netscape") {
}
else {
document.write("");
}
function changeCharColor() {
if (navigator.appName == "Netscape") {
document.a.document.write("");
for (var j = 0; j < text.length; j++) {
if(j == i) {
document.a.document.write("" + Text.charAt(i) + "");
}
else {
document.a.document.write(text.charAt(j));
}
}
document.a.document.write('
');
document.a.document.close();
}
if (navigator.appName == "Microsoft Internet Explorer") {
str = "";
for (var j = 0; j < text.length; j++) {
if( j == i) {
str += "" + text.charAt(i) + "";
}
else {
str += text.charAt(j);
}
}
str += "
";
a.innerHTML = str;
}
(i == text.length) ? i=0 : i++;
}
setInterval("changeCharColor()", speed);
// End -->
《script》

运行效果


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

HTML5培训技术

本文由欣才IT学院整理发布,未经许可,禁止转载。
支持22不支持0