首页 > 其他 > 详细

Dom选择器使用与调试记录

时间:2018-04-05 10:27:26      阅读:164      评论:0      收藏:0      [点我收藏+]
<!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

 

Dom选择器使用与调试记录

原文:https://www.cnblogs.com/qiangayz/p/8720546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!