Insertion Outside Flashcards

1
Q

Insert element before single target

target.before(element);

A

element.insertAdjacentHTML(position, text);

‘beforebegin’

Before the element itself.

‘afterbegin’

Just inside the element, before its first child.

‘beforeend’

Just inside the element, after its last child.

‘afterend’

After the element itself.

OR

The Node.insertBefore() method inserts the specified node before the reference node as a child of the current node.

text is the string to be parsed as HTML or XML and inserted into the tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

element.after(htmlString)

A

el.insertAdjacentHTML(‘afterend’, htmlString)

OR

element.parentNode.insertBefore(newElement, element.nextSibling);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly