-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (32 loc) · 965 Bytes
/
script.js
File metadata and controls
43 lines (32 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$(document).ready(function(){
var $randomnbr = $('.nbr');
var $timer= 10;
var $it;
var $data = 0;
var index;
var change;
var letters = ["w", "e", "l", "c", "o", "m", "e"];
$randomnbr.each(function(){
change = Math.round(Math.random()*100);
$(this).attr('data-change', change);
});
function random(){
return Math.round(Math.random()*9);
};
function select(){
return Math.round(Math.random()*$randomnbr.length+1);
};
function value(){
$('.nbr:nth-child('+select()+')').html(''+random()+'');
$('.nbr:nth-child('+select()+')').attr('data-number', $data);
$data++;
$randomnbr.each(function(){
if(parseInt($(this).attr('data-number')) > parseInt($(this).attr('data-change'))){
index = $('.ltr').index(this);
$(this).html(letters[index]);
$(this).removeClass('nbr');
}
});
};
$it = setInterval(value, $timer);
});