Go back to the main page

Use jQuery to append to a tags content rather than replace

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

 

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'; });
Comment on this article?