javascript add adjacent html 1

javascript add adjacent html

ul = document.querySelector('ul');

  • Hello
  • '); //
    • Hello
    • //

    Here is what the above code is Doing:
    1. We select the ul element.
    2. We use the insertAdjacentHTML() method to insert a new li element at the beginning of the ul element.
    3. The first argument of the insertAdjacentHTML() method is the position relative to the ul element where we want to insert the new li element.
    4. The second argument is the HTML we want to insert.

    Similar Posts