Home > front end >  Turn to page HTML structure known as follows on the premise of not to modify the static structure th
Turn to page HTML structure known as follows on the premise of not to modify the static structure th

Time:09-16

Page HTML structure known as: & lt; Ul>
  • List2 & lt;/li>
  • , without any change in the static structure of the premise, through the js code, after the page is loaded, add a new list item to ul element dynamic,
    Urgent urgent someone know

    CodePudding user response:

     

    • List1 & lt;/li>
    • List2 & lt;/li>
    • List3 & lt;/li>


    <script>
    //loaded
    Window. The onl oad=function () {
    Var ul=document. QuerySelector (' ul ')
    Var li=document. The createElement method (' li ')
    Li. The innerText='I am a new'
    Ul. The appendChild (li)
    }
    </script>
    • Related