Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //calling the function in window.onload to make sure the HTML is loaded
- window.onload = function() {
- var posLeft = 0;
- var posTop = 150;
- //our box element
- var box = document.getElementById('box');
- var t = setInterval(move, 10);
- var moveDown = setInterval(cac, 10);
- function move() {
- if(posLeft >= 150) {
- clearInterval(t);
- }
- else {
- posLeft += 1;
- box.style.left = posLeft+'px';
- }
- }
- function cac() {
- if(posLeft >= 150 && posTop >= 0) {
- posTop -= 1;
- box.style.bottom = posTop+'px';
- }
- else if(posTop == 0) {
- clearInterval(moveDown);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement