DOM insertAdjacentHTML

DOM insertAdjacentHTML.

The locations work as such (I list the equivalent terminology):

.insertAdjacentHTML("beforeBegin", ...) before
.insertAdjacentHTML("afterBegin", ...) prepend
.insertAdjacentHTML("beforeEnd", ...) append
.insertAdjacentHTML("afterEnd", ...) after

The method is only available on DOM elements (which makes sense) and is easy to use:

var ul = document.getElementById(“list”);
ul.insertAdjacentHTML(“beforeEnd”“<li>A new li on the list.</li>”);
ul.insertAdjacentHTML(“beforeEnd”“<li>Another li!</li>”);

 

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s