As an easter egg for a part of one of my sites, I have in my footer #left tag a "Easter" egg that changes each time you click it, revealing funny messages:
$('#left').append(" <span><a href='#' id='dontclick1'>Don't click.</a></span>");
// time for some fun
$('#dontclick1').click(function() {
$('#left span').html("<a href='#' id='dontclick2'>I told you not to click.</a>");
return false;
});
$('#dontclick2').click(function() {
$('#left span').html('<a href="#" id="dontclick3">Now you will suffer.</a>');
return false;
});
$('#dontclick3').click(function() {
$('#left span').html('<a href="#" id="dontclick4">Shame!</a>');
return false;
});
$('#dontclick4').click(function() {
$('#left span').html('<a href="#" id="dontclick5">You shouldn't click.</a>');
return false;
});
$('#dontclick5').click(function() {
$('#left span').html('<a href="#" id="dontclick6">But you did. Sigh.</a>');
return false;
});
In my footer, the append adds the message dynamically so people without JavaScript won't see something unclickable. However, the first time it's clicked, it changes to the second message, but it won't work after that.
What am I doing wrong? Is it because of the return false
inside there? Without it, it jumps to the top of the page. I'm confused.