Q.1
11
2
3
4
5
6const images=[
'1.png',
''//相对路径
]
CONST randomiImage=images[Math.floor(Math.random()*images.length)];
document
document可以获取1
2
3
4
5const element = document.getElementById('myId');//通过id获取
const elements = document.getElementsByClassName('myClass');//通过类获取
const elements = document.getElementsByTagName('p');//标签
const element = document.querySelector('.myClass');//单个元素
const elements = document.querySelectorAll('.myClass');//多个元素1
2
3
4
5
6
7
8
9
10console.log(document.title); // 获取或设置页面标题
document.title = "新标题"; // 修改标题
console.log(document.URL); // 当前页面的完整 URL
console.log(document.domain); // 当前页面的域名
文档类型:
console.log(document.doctype.name); // 返回文档类型,例如 'html'
console.log(document.lastModified); // 返回文档的最后修改日期和时间
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LoscX!