We want to make this open-source project available for people all around the world.

Help to translate the content of this tutorial to your language!

BuyEPUB/PDF
Share
back to the lesson

Insert the HTML in the list

importance: 5

Write the code to insert <li>2</li><li>3</li> between two <li> here:

<ul id="ul">
 <li id="one">1</li>
 <li id="two">4</li>
</ul>

When we need to insert a piece of HTML somewhere, insertAdjacentHTML is the best fit.

The solution:

one.insertAdjacentHTML('afterend', '<li>2</li><li>3</li>');

AltStyle によって変換されたページ (->オリジナル) /