Home >Web Front-end >JS Tutorial >JavaScript method to achieve typing effect_javascript skills

JavaScript method to achieve typing effect_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:50:371127browse

The example in this article describes how JavaScript can achieve typing effects. Share it with everyone for your reference. The specific implementation method is as follows:

<input type="button" onclick='start("高考了")' value="start"/>
<input type="text" id="here" />
<script type="text/javascript">
function start(str1)
{
str=str1;
len=str.length;
i=0;
dwrite();
}
function dwrite()
{
  document.getElementById('here').value=document.getElementById('here').value + str.charAt(i);
  if( i++ ==len )
  {
   i=0;
   return true;
  }
  setTimeout('dwrite()',500);
}
</script>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn