jQuery toggleClass example

Toggle class name on click in jQuery

by GBNet

HTML

<div id="test">
    <textarea id="sp">Ce petit script en JQuery (trois lignes effectives) permet de reproduire la frappe d'une machine à écrire à une vitesse aléatoire. Il est ultra-léger et entièrement modulable.</textarea>
    <div id="cont">
        <p id="rs" >
        </p>
    </div>    
</div>

CSS

body{background-image: url('112.png');}
#test{width: 1px; height:1px;}
#cont {width: 630px;height:180px;overflow:hidden;}
#rs {line-height:51px;margin-top:16px;margin-left:89px;text-align:left;width:560px;height:180px;overflow:hidden;font-family:my_under;font-size:16px;}

JavaScript

var array = Array.from($("#sp ").val());
$("#sp").hide();
var i = 0;
var rand; 
//var audio = new Audio('key.mp3'); 
for(y=19;y<25;y++) { 
   array[y] = '<span style="color:#CF0202;">'+array[y]+'</span>'; 
}

function Write(){
  //audio.play();
 /* if(i == 5) {
    $("#rs").append("<br />");
  }*/
  
 $("#rs").append(array[i]);
 rand = Math.floor(Math.random() * (600 - 24 + 1)) + 24;
 if(i<array.length) {
    setTimeout(Write,rand);
 }
 i++;
}
Write();