js实现字符串一个一个依次显示
一:
<script language="javascript">
var index=0;
var str=document.getElementById("string").innerHTML;
function type(){
if(index==str.length){index=0;}
document.getElementById("showStr").innerText = str.substring(0,index++);
}
setInterval(type, 500);
</script>
二:
<script type="text/javascript">
window.onload = type;
var index = 0;
var word = $("#w").html();
function type(){
$("#aa").html(word.substring(0,index++));
if(index > word.length) {
return;
} else {
setTimeout(type,430);
};
}
</script>
原文链接:https://blog.csdn.net/liu__hua/article/details/38869615