Uncaught TypeError: Failed to execute 'insertAdjacentElement' on 'Element': parameter 2 is not of type 'Element' code example

Example: Uncaught TypeError: Failed to execute 'insertAdjacentElement' on 'Element': parameter 2 is not of type 'Element'

The second parameter of insertAdjacentElement() should be a html object.
The trick below works :)


var htmlString = `
${obj.descripiton}
${obj.value}
` var htmlObject = document.createElement('div'); htmlObject.innerHTML=htmlString; document.querySelector(".income__list").insertAdjacentElement('beforeend', htmlObject);

Tags:

Misc Example