Skip to content

Instantly share code, notes, and snippets.

@andyg2
Created December 14, 2022 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyg2/a55b3f584a0ce5df734f7d9c3f039bdd to your computer and use it in GitHub Desktop.
Save andyg2/a55b3f584a0ce5df734f7d9c3f039bdd to your computer and use it in GitHub Desktop.
Add a bouyant message on click
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