<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="#12">我喜欢学习python</div> <a>123</a> <a>456</a> <a>789</a> </body> </html> document.getElementById(‘#12‘) <div id=?"#12">?我喜欢学习python?</div>? document.getElementById(‘#12‘).innerText "我喜欢学习python" document.getElementById(‘#12‘).innerText="我也超级喜欢" "我也超级喜欢" document.getElementsByTagName(‘a‘)[1] <a>?456?</a>? document.getElementsByTagName(‘a‘)[1].innerText=‘qwe‘ "qwe" msg = document.getElementsByTagName(‘a‘) HTMLCollection(3) [a, a, a] for(var i=0;i<msg;i++){msg[i].innerText=111} undefined for(var i=0;i<msg;i++){msg[i].innerText=111;} undefined for(var i=0;i<msg.length;i++){msg[i].innerText=111} 111
原文地址:https://www.cnblogs.com/qiangayz/p/8720546.html
时间: 2024-11-29 16:27:50