Go back to the main page

Use jQuery to append to a tags content rather than replace


You want to just add to the end of a tag's contents and not replace the entire contents like .html() does. Do the following:

  // Example
  $('#element').html(function(i,currentContents){ return currentContents + ' appended content'; });
  • Pushed on 05/30/2013 by Christian