Skip to content

Instantly share code, notes, and snippets.

@bogoreh
Created March 11, 2021 12:22
Show Gist options
  • Select an option

  • Save bogoreh/58f572d8da25dec5b2e2ebe9bc941526 to your computer and use it in GitHub Desktop.

Select an option

Save bogoreh/58f572d8da25dec5b2e2ebe9bc941526 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Spin-off of "Challenge: Cat-stache"</title>
<style>
#mustache-pic {
position: absolute;
}
</style>
</head>
<body>
<img id="cat-pic" src="https://www.kasandbox.org/programming-images/animals/cat.png" width="300" alt="cat photo">
<img id="mustache-pic" src="https://www.kasandbox.org/programming-images/misc/mustache.png" alt="mustache" width="100">
<script>
var catPic = document.getElementById("cat-pic");
var onCatClick = function(e) {
var stashePic = document.getElementById("mustache-pic");
stashePic.style.top = e.clientY+"px";
stashePic.style.left = e.clientX+"px";
};
catPic.addEventListener("click", onCatClick);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment