js实现字符串一个一个依次显示
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>
一:
<textarea id="showStr"></textarea>
<div style="display:none" id="string">请在此输入您想咨询的问题
</div>
<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>
二:
<p id="aa" class="string"></p>
<p style="display:none" id="w">请在此输入您想咨询的问题</p>
<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>
</body>
</html>
原文链接:https://blog.csdn.net/liu__hua/article/details/38869615
最新文章
- linux-rpm
- [ios]纯代码实现UITableViewCell的自定义扩展
- oracle学习 一 (持续更新中)
- .net MVC 下载文件乱码问题解决方案
- 微软职位内部推荐-Data Scientist
- C++智能指针(auto_ptr)详解
- 动态分配内存补充 realloc
- The Swift Programming Language--语言指南--协议
- 微信小程序之提高应用速度小技巧
- Spring的JDBC(非web程序)的简单例子
- 使用supervisor管理进程
- ubunto启动chrome报错
- 【UVA】11400 照明系统设计 排序+dp
- 生产环境Linux常用命令【随时更新】
- C#缓存absoluteExpiration、slidingExpiration两个参数的疑惑
- PL/SQL Developer显示中文乱码
- SRM470
- pgm8
- tar 使用总结
- [CoreOS 转载] CoreOS实践指南(三):系统服务管家Systemd