简体   繁体   中英

Change image x and y co-ordinate on mouse hover

I have one image what I want to is: change its x & y position on mouse move.

for example:

  <div class="mover" id="1"> <IMG SRC="images/buttons1.png" WIDTH=129 HEIGHT=30 ALT="" border="0"/> </div> <div class="mover" id="2"> <IMG SRC="images/buttons2.png" WIDTH=129 HEIGHT=30 ALT="" border="0"/> </div> 

What I want to do is like normal flash menus when my mouse come on " buttons1.png " a blue dot image show in the beginning of button and when mouse leave the " buttons1.png " this blue dot disappear.

I want to repeat same for my both images.

Check out:

Example:

 $(".button").mouseenter(function() { var position = $(this).position(); $("#dot").css("left", position.left+10) .css("top", position.top+5) .show(); }).mouseleave(function() { $("#dot").hide(); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="mover" id="2"> <img class="button" src="images/buttons1.png" width="129" height="30"/> <img class="button" src="images/buttons2.png" width="129" height="30"/> </div> <img id="dot" style="display: none; position: absolute;" src="images/blue_dot.png"/> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM