Skip to content

Instantly share code, notes, and snippets.

@bogoreh
Last active June 4, 2024 08:36
Show Gist options
  • Select an option

  • Save bogoreh/3c39fd7bbf75ea62798c014dea5052bd to your computer and use it in GitHub Desktop.

Select an option

Save bogoreh/3c39fd7bbf75ea62798c014dea5052bd 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>
@bogoreh
Copy link
Copy Markdown
Author

bogoreh commented Jun 4, 2024 via email

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