<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title></title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script type= "Text/javascript" src= "Js/jquery.min.js" ></script>
<script type= "Text/javascript" >
Class
var _pos = 0; Initial position
var _direcation = 1; Initial direction, 1 for x+ direction,-1 for x direction
var _x = 5; Max width
var _y = 40; Maximum height
Dynamic Update
function Update () {
var pos = _pos; Current position
var direcation = _direcation; Current direction
var output = ';
for (var i=0; i<_y; i++) {
Output + + ' <div> ' + RP ('. ', POS) + ' drifting over </div> ';
if ((pos<=0&&direcation<=0) | | (pos>=_x&&direcation>=0))
Direcation *=-1; Update direction
POS + + direcation * 1; Update location
}
$ (' #happy '). html (output);
Update initial data
if ((_pos<=0&&_direcation<=0) | | (_pos>=_x&&_direcation>=0))
_direcation *=-1; Update direction
_pos + = _direcation * 1; Update location
}
Repeat output string n times
function RP (Str,len) {
if (!len&&len!==0) Len + + 2;
return new Array (len+1). Join (str);
}
</script>
<style type= "Text/css" >
body,html{font-size:12px; letter-spacing:0.2em;}
div{margin:5px 20px;}
</style>
<body>
<div id= "Happy" ></div>
<script type= "Text/javascript" >
SetInterval (' Update () ', 80);
</script>
</body>