jQuery Append


  1. $(selector).append(content)
  2. $(content).appendTo(selector)


contentPossible types: Element, HTML string, text, array, object or even a function returning a string.


  • .append() & .after() can potentially execute code. This can occur by injection of script tags or use of HTML attributes that execute code (for example, ). Do not use these methods to insert strings obtained from untrusted sources such as URL query parameters, cookies, or form inputs. Doing so can introduce cross-site-scripting (XSS) vulnerabilities. Remove or escape any user input before adding content to the document.

  • jQuery doesn't officially support SVG. Using jQuery methods on SVG
    documents, unless explicitly documented for that method, might cause unexpected behaviors. Examples of methods that support SVG as of
    jQuery 3.0 are addClass and removeClass.