Last active
December 26, 2015 19:09
-
-
Save evelynriossf/7199674 to your computer and use it in GitHub Desktop.
KittyCat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Cat Walk</title> | |
</head> | |
<body> | |
<img id="kittyCat"; style="position:absolute;" src="http://www.anniemation.com/clip_art/images/cat-walk.gif"> | |
</body> | |
</html> | |
<script> | |
var kittyCat = document.getElementById('kittyCat'); | |
kittyCat.style.left = "0px"; | |
function catWalk () { | |
var oldLocation = parseInt(kittyCat.style.left); | |
var newLocation = oldLocation + 10; | |
kittyCat.style.left = newLocation + 'px'; | |
if (parseInt(kittyCat.style.left) > window.innerWidth - 30){ | |
kittyCat.style.left = "0px"; | |
} | |
} | |
window.setInterval(catWalk, 50); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment