アットウィキロゴ

ボタン87

<html>
<meta charset="utf-8"/>
<head>
<title>sample</title>
<script src="jquery.js"></script>
<script src="sample.js"></script>
</head>
<body onload="sample()">
<p id="memo"></p>
<input id="bt" type="button" value="stop" />
<input id="bt2" type="button" value="start" />
</body>
</html>
 
 
 
 
var x;
 
function sample(){
 
    x=100;
 
    $("#bt").click(function(){
        x=200;   
        });
 $("#bt2").click(function(){
        x=100;   
        });
 
    game();
 
}
 
function game(){
 
var timer;
var delay = 100;
 
var p=100;    
 
var loop = function(){
 
 
if(x<150)p=p+1;    
 
$("#memo").html(p);
 
 
clearTimeout(timer);
timer = setTimeout(loop,delay);
}
 
loop();
 
}
 
最終更新:2015年05月10日 02:16