Python List append() Function
Python provides the
append() function for the list data type. The list is a data type used to store multiple items in a single data structure with a single variable. append() will add some items to this list.
- LIST is the list object where we want to add a new item.
- ITEM is the item we will add to the LIST.
Now we will create a list named “mycars” and add new items to this list object by using the append() method.
mycars = ['hyundai','ferrari'] mycars.append('mercedes') mycars.append('bmw') print(mycars)
- ParentNode is the DOM object we will add.
- ITEM is the HTML orDOM item which will be added under the ParentNode.
In the following example we will create a div element and add “This text is added with append() function” as text inside this div element.
let p= document.createElement("div") p.append("This text is added with append() function")
jQuery append() Function
In the following example we will select the class named “container” and then add some text inside this class object.
$( ".container" ).append( "This text will be appended() under the class .container" );