views:

191

answers:

2

Duplicate: How would I implement StackOverflow's hovering dialogs?


I'm trying to create an error message, that is being displayed, so far here's a crude attempt, the message displays fine, however the click doesn't work..

function message(somemessage){
       $(document).ready(function(){
            $('<div class="error">' + somemessage+ '</div>')
           .insertAfter( $('#ErrorMessage') ).fadeIn('slow').animate({opacity: 1.0}, 5000).click(function(){$(this).remove});
   });
 }
+9  A: 

I've already answered how to do this in this question.

If you want, just skip straight to the example.

However, if you want something more robust, you should check out the many solutions out there:

If you wanted to see how to do the other notifications used in this website (the ones at the top when you earn a new badge, etc) you can check out how to do that in this question.

Paolo Bergantino
+1 wow, Paolo is awesome..lol
TStamper
+4  A: 

Isn't it because you forgot to add parenthesis after the remove function?

Try this

$('<div class="error">' + "somemessage"+ '</div>')
           .insertAfter( $('#ErrorMessage') ).fadeIn('slow').
animate({opacity: 1.0}, 5000).click(function(){$(this).remove()});
Elazar Leibovich