1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> </head> <body> <ul class="container"> <li>我</li> <li>喜</li> <li>欢</li> <li>你</li> </ul> <script> const lis= document.querySelectorAll(".container>li"); for(let i=lis.length-1; i>-1; i--){ document.querySelector(".container").appendChild(lis[i]); } </script> </body> </html>
|