![]()
Please help me on this!
![]()
Please help me on this!
What do you mean "change location" ?? Change it's position on the screen(like animating) or do you want it's target to change?
Oh, it's extremely easy. Just change the element's left and top properties. If you dunno how to see this example:
The js:
Code:function move(){ some_element = document.getElementById("some_id"); some_element.style.left = "100px"; // moves the element some_element to 100px from the left some_element.style.top = "100px"; // moves the element some_element to 100px from the top }Code:<input type="button" onclick="move()" id="some_id">
Watch and learn.how could the final result look like^ I mean what should I write in the "some_element"? (its the button i want to be some_element?) how?!?
Just paste it like this:
Again, this isn't what you wanted but just an example. It's your school project not mine.Code:<html> <head> <script type="text/javascript"> function move(){ var some_element = document.getElementById("some_id"); some_element.style.left = "100px"; // moves the element some_element to 100px from the left some_element.style.top = "100px"; // moves the element some_element to 100px from the top } </script> </head> <body> <input type="button" onclick="move()" id="some_id" style="position: absolute;"> </body> </html>
Bookmarks