运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to check if the ul element with id="myList" is the same as the document's first ul element. If so, add a color to its first child.</p> <button onclick="myFunction()">Try it</button> <ul id="myList"><li>Coffee</li><li>Tea</li></ul> <script> function myFunction() { var item1 = document.getElementById("myList"); var item2 = document.getElementsByTagName("UL")[0]; if (item1 === item2) { alert("THEY ARE THE SAME!!"); } else { alert("They are not the same."); } } </script> </body> </html>