JS DOM equivalent for JQuery append

dom, javascript, jquery

Solution

I think you have to extend the innerHTML property to do this

element[0].innerHTML += "<ul><li><a href='url'></a></li></ul>";

some explanation:

- [0] needed because `element` is a collection

- += extend the innerHTML and do not overwrite

- closing `</a>` needed as some browsers only allow valid html to be set to innerHTML

Hint: As @dontdownvoteme mentioned this will of course only target the first node of the collection `element`. But as is the nature of jQuery the collection could contain more entries

Problem

What is the standard DOM equivalent for JQuery `element.append("<ul><li><a href='url'></li></ul>")`?

Original source