What is the standard DOM equivalent for JQuery
element.append("<ul><li><a href='url'></li></ul>")
?
replaceChildren() is a convenient alternative to innerHTML and append() append() appends nodes to the parent node. The contents that were inside the node before the append() invocation remain preserved.
The jQuery append() method lets you insert content (either an element or a string) at the end of each element in a set of matching elements.
Introduction to JavaScript append() methodThe append() method will insert DOMString objects as Text nodes. Note that a DOMString is a UTF-16 string that maps directly to a string. The append() method has no return value. It means that the append() method implicitly returns undefined .
jQuery append() Method The append() method inserts specified content at the end of the selected elements. Tip: To insert content at the beginning of the selected elements, use the prepend() method.
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:
element
is a collection</a>
needed as some browsers only allow valid html to be set to innerHTMLHint: 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With