Curious about hide().after("") in jQuery

That's cause you're creating paragraphs

<p>hello world</p>

and on every click the $('p') is a collection of all p elements on your page.
The more paragraphs you have... more appends. live demo - issue example

An element, even if set to display:none using .hide(), is still present in your document..


What you're up to is probably one of the following:

  $("button").click(function(){
      $("p").html('hello world');
  });

  $("button").click(function(){
      $("p").text('hello world');
  });

  $("button").click(function(){
      $("p").replaceWith('<p>hello world</p>');
  });

  $("button").click(function(){
    $("p").after('<p>Hello world</p>').remove();
  });