Created
December 14, 2022 12:50
-
-
Save andyg2/a55b3f584a0ce5df734f7d9c3f039bdd to your computer and use it in GitHub Desktop.
Add a bouyant message on click
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
var a_idx = 0; | |
$(document).on("click", function (e) { | |
var a = new Array("Click!". "Another Click!", "Add loads"); | |
var $i = $("<span/>").text(a[a_idx]); | |
a_idx = (a_idx + 1) % a.length; | |
var x = e.pageX, | |
y = e.pageY; | |
$i.css({ | |
"z-index": 999999999999, | |
"top": y - 20, | |
"left": x, | |
"position": "absolute", | |
"font-weight": "bold", | |
"color": "#f00" | |
}); | |
$("body").append($i); | |
$i.animate({ | |
"top": y - 180, | |
"opacity": 0 | |
}, | |
1500, | |
function () { | |
$i.remove(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment