亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

基于jQuery實(shí)現(xiàn)的打字機(jī)效果

 更新時(shí)間:2017年01月16日 08:50:32   作者:1379089794  
本文主要分享了基于jQuery實(shí)現(xiàn)的打字機(jī)效果的示例代碼。具有一定的參考價(jià)值,下面跟著小編一起來看下吧

 話不多說,請(qǐng)看實(shí)例代碼:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="keyword" content="">
<meta name="description" content="">
</head>
<body>
<div class="autotype" id="autotype">
 <p>一場(chǎng)雨把我困在這里</p>
 <br/>
 <p>你溫柔的表情</p>
 <p>會(huì)讓我傷心</p>
 <br/>
 <p>六月的雨,只是無情的你~</p>
</div>
<script src="http://file2.ci123.com/ast/js/jquery_172.js"></script>
<script>
 $.fn.autotype = function(){
  var $text = $(this);
  console.log('this',this);
  var str = $text.html();//返回被選 元素的內(nèi)容
  var index = 0;
  var x = $text.html('');
  //$text.html()和$(this).html('')有區(qū)別
  var timer = setInterval(function(){
   //substr(index, 1) 方法在字符串中抽取從index下標(biāo)開始的一個(gè)的字符
   var current = str.substr(index, 1);
   if(current == '<'){
   //indexOf() 方法返回">"在字符串中首次出現(xiàn)的位置。
    index = str.indexOf('>', index) + 1;
   }else{
    index ++ ;
   }
   //console.log(["0到index下標(biāo)下的字符",str.substring(0, index)],["符號(hào)",index & 1 ? '_': '']);
   //substring() 方法用于提取字符串中介于兩個(gè)指定下標(biāo)之間的字符
   $text.html(str.substring(0, index) + (index & 1 ? '_': ''));
   if(index >= str.length){
    clearInterval(timer);
   }
  },100);
 };
 $("#autotype").autotype();
</script>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論