4. Creating new HTML elements #
Created Sunday 12 July 2020
We have a shopping list and want to add a new item to the list. Steps to create an element.
- Create the element object using document.createElement(‘tag’);
- Add the content using document.createTextNode(newitem);
- Set the attributes, classes using set attribute.
- Attach the eObj to the required element using par.appendChild(eObj);
Note: Objects can be deleted using eObj.remove();