Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Brandon Spangler
Brandon Spangler
8,756 Points

Is the function .insertAdjacentHTML() considered bad form/outdated?

Is .insertAdjacentHTML() out of date? I used it to write my own function instead of Gil's function. This is my function:

function attachListItemButtons(el) {
    let htmlStr = `<button class="up">Up</button>
                    <button class="down">Down</button>
                    <button class="remove">Remove</button>`;
  el.insertAdjacentHTML('beforeend',htmlStr);
}

I just want to know if we typically want to use the method Gil used, i.e., using element properties as much as possible.

1 Answer

Steven Parker
Steven Parker
229,783 Points

In the MDN page, it's not marked as either deprecated or experimental, and Can I Use? indicates that it is well supported.