Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
</head>
<body oncontextmenu="return false;">
Value:<br> <p id="Value"> 0 </p>
<p>Click the ball to increase the value.</p>
<input type="image" onmousedown="increase()" src="RedBall.png" id="demp" style="position:relative; left: 500px; top: 80px; width: 32px; height: 32px;"></button>
<script>
function increase() {
    var x = document.getElementById("Value").innerHTML;
    var increased = parseInt(x,10) + parseInt(1,10);
    document.getElementById("Value").innerHTML = increased;
}
function change(){
    var num = 0;
    window.setInterval(function(){
    var speedx= Math.floor((Math.random() * 11) - 5);
    var speedy= Math.floor((Math.random() * 11) - 5);
    document.getElementById("demp").style.left= parseInt(document.getElementById("demp").style.left, 10) + parseInt(speedx,10) +"px"; 
    document.getElementById("demp").style.top= parseInt(document.getElementById("demp").style.top, 10) + parseInt(speedy,10) +"px"; 
    }, 10)
}
window.onload = function start() {
    change();
    document.body.onselectstart = function() {
        return false;
    }
}
</script>
</body>
</html>
Output 300px

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers