Toggle func - problems

Toggle func - problems

Hi,

I want to show and hide a div with content. Ok, there is the slideToggle
func but which doesn't fit my requirements totally. I also want to change
text and a class. So I was writing this little func:

      $("#message_history").hide();
      
      $("a.history").toggle(
         function() {
            $("#message_history").slideDown();
            $(this).replaceWith("<a class='history' href='#'>"+"show History"+"</a>");
            return false;
         },
         function() {
            $("#message_history").slideUp();
            $(this).replaceWith("<a class='history' href='#'>"+"hide History"+"</a>");
            return false;
         });


Well, clicking on the link slides down the div and also the text get changed.
The change class thing is not implemented yet. Clicking one again,
nothing happens unless I delete the text changing part.
Could you please explain why jQuery is not chaning anything then and
what could be a solution for it?

thanks indeed
T.C.