<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0px;
padding: 0px;
}
.zimu{
width: 30px;
height: 30px;
position: absolute;
border-radius: 50%;
text-align: center;
}
</style>
</head>
<body>
<span id="count"></span>
</body>
<script src="js/jquery-1.11.0.js"></script>
<script>
var score = 0;
function ran(max,min){
return Math.round(Math.random()*(max-min)+min);
}
$(function(){
function create(){
var r = ran(255,0);
var g = ran(255,0);
var b = ran(255,0);
var a = ran(1,0.5);
var k = ran(90,65);
var ch = String.fromCharCode(k);
var left = ran(document.documentElement.clientWidth,0);
var top = ran(document.documentElement.clientHeight,0);
console.log(k);
$('body').append('<span class="zimu zimu'+k+'"style="background-color: rgba('+r+','+g+','+b+','+a+');top:'+top+'px;left:'+left+'px;">'+ch+'</span>');
}
setInterval(create,1100);
})
$(document).keyup(function(event){
var keycode = event.keyCode;
$(".zimu"+keycode).animate({
'top':+200,
'opacity':0,
},'slow')
$(".zimu"+keycode).hide('slow',function(){
score+=20;
$("#count").html(score);
$(this).remove();
console.log($(".zimu").length);
})
})
</script>
</html>
网友评论