Tricky Button Moving Away when Mouseover in Javascript? [closed]

自闭症网瘾萝莉.ら 提交于 2020-01-11 17:10:30

问题


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


来源:https://stackoverflow.com/questions/11929687/tricky-button-moving-away-when-mouseover-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!