<script> function handler() { document.getElementById("myDIV").style.left = "100px"; } </script> 

this changes the position of the diva once tell me how to make the position change after each subsequent pressing

    2 answers 2

     <script> function handler(p) { var e = document.getElementById("myDIV"); e.style.left = p?(parseInt(e.style.left||0)+p)+"px":""; } </script> 
    • How to return a div to its original position? - Andrew
    • document.getElementById("myDIV").style.left = ''; - webDev_
    • This line where to add? create a new feature? - Andrew
    • made the changes. enter how much you need to change the position of the div handler(100) or to return it to the place of handler(0) - webDev_
    • Anyway, I don’t understand how to do this. Do I need to create a new handler? or replace the parameter e? - Andrew
     <script> function handler(event) { event.currentTarget.style.left = new String(event.currentTarget.offsetLeft+100) + "px"; } </script> 

    I hope this is what you need