Tricky Button Moving Away when Mouseover in Javasc

2020-05-19 04:05发布

问题:

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 7 years ago.

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.

回答1:

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",
            });
        }
    });
});​