Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

append
add
jquery
attach

What is the "append" method in jQuery?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

In jQuery, the append() method is used to insert specified content as the last child (at the end of) the selected elements in the jQuery collection.

Within an HTML document, there are multiple elements. For each element, you might want to attach new elements or objects to an older element i.e. append() an element as the last child of an existing parent element.

The screen shows Hello in style h1
1 of 3

Syntax

First, we will look at the syntax of the append() method and see how it works.

Examples

The append() method has two implementations:

  1. The first implementation simply calls the append() method as a function of the $(selector) and gives the element to be appended as the argument. The appended element can be an HTML or DOM element or a jQuery tag.
  • HTML
  1. The second implementation takes in a method as input instead of the element or content to be appended. In this case, the input method returns an element or content that is to be appended.
  • HTML

Note: If you keep on clicking the button, it will keep appending the text to the already created element.

RELATED TAGS

append
add
jquery
attach
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring