Skip to content

Instantly share code, notes, and snippets.

@appikonda
Last active August 29, 2015 14:14
Show Gist options
  • Save appikonda/75015c251458457a4d95 to your computer and use it in GitHub Desktop.
Save appikonda/75015c251458457a4d95 to your computer and use it in GitHub Desktop.
assignment5
<html>
<head>
<titl>Assignment #5</titl>
</head>
<style>
.move-me {
height: 200px;
width: 200px;
position: absolute;
background-color: #ff0000;
left: 10px;
}
</style>
<body>
<div class="move-me" onmouseover = "moveIt()" ></div>
<script>
// Explanation: https://www.youtube.com/watch?v=4y8JHE6UKCo&feature=youtu.be
// The red box being displayed below should move 100px to the right each time you hover over it.
var incrementValue = 100;
var col=document.getElementsByClassName('move-me')[0];
var left_px=col.offsetLeft;
function moveIt(){
col.style.left= this.left_px + this.incrementValue;
this.incrementValue = this.incrementValue+100;
}
</script>
</body>
</html>
@mohnish
Copy link

mohnish commented Feb 6, 2015

👍 :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment