Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 202
HP. Avatar asked Aug 13 '12 07:08

HP.


1 Answers

This is probably what you are looking for:

$(function() {
  $("button").on({
    mouseover: function() {
      $(this).css({
        left: (Math.random() * 200) + "px",
        top: (Math.random() * 200) + "px",
      });
    }
  });
});
button {
  position: absolute;
  top: 10px;
  left: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>button</button>

http://jsfiddle.net/9CDtE/4/

like image 190
Gautam Avatar answered Nov 02 '22 02:11

Gautam