Tricky Button Moving Away when Mouseover in Javascript?

HP. picture HP. · Aug 13, 2012 · Viewed 27.5k times · Source

I remember seeing some website or script on the web about this funny / tricky button: Basically it's a button that is impossible to click. When mouseover, it moves randomly away.

Can someone point me to a source or show me few line of code to do that? Preferably using jQuery.

Answer

Gautam picture Gautam · Aug 13, 2012

This is probably what you are looking for, http://jsfiddle.net/9CDtE/4/

HTML

<button>button</button>​

CSS

button{
    position:absolute;
    top:10px;
    left:10px;
}​

JS

$(function(){
    $("button").on({
        mouseover:function(){
            $(this).css({
                left:(Math.random()*200)+"px",
                top:(Math.random()*200)+"px",
            });
        }
    });
});​