How to move a button using Javascript on MouseOver

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SEhtesham
    New Member
    • Aug 2011
    • 45

    How to move a button using Javascript on MouseOver

    hi,
    I want to move a button to new location at the mouseOver event in JavaScript..
    Please have a look at my code below.
    Code:
    function move() {
       b1.style.position = "relative";
       setTimeout(b1.style.left = 100,1000)
       }
    
    <input type="button" name="b1" value="click" onmouseover="move()"/>
    Im able to move the button to the new location but its moving very fast,I want to move the button slowly.Much like when we use .hide("slow")
    I have tried using setTimeout(b1.s tyle.left = 100,1000) but its not working..
    Please guide how to do it
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    1) style.left expects a value with unit, e.g. 100px or 2em
    2) for a movement, you need an animation. what you currently have is a single step.

    Comment

    Working...