Web API Document All In One
Web API Document All In One
document
document;
https://developer.mozilla.org/en-US/docs/Web/API/Document
document.all ?
已弃用
typeof document.all
// 'undefined'
document.all;
https://developer.mozilla.org/en-US/docs/Web/API/Document/all
TypeScript
HTMLElement
/ HTMLCollectionOf / NodeListOf
// const dom = document.querySelector(selector);
// const dom: Element | null
// ?
// const dom = document.querySelector(selector) as Element;
// ?
// const dom = document.querySelector(selector);
// ?
// const dom = document.querySelector(selector);
// ?
const dom = document.querySelector(selector) as HTMLElement;
// console.log('\nbackground =', background);
// console.log('\ndom =', dom);
if (dom) {
dom.style.background = background;
}
// ?
const doms = document.querySelectorAll(selector) as NodeListOf;
// ?
// const doms = document.querySelectorAll(selector) as HTMLCollectionOf;
// ?
// const doms = (NodeList)document.querySelectorAll(selector);
// ?
// const doms = (HTMLCollection)document.querySelectorAll(selector);
if (doms) {
doms[0].style.background = background;
}
https://www.typescriptlang.org/docs/handbook/dom-manipulation.html
https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts
refs
?xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有??xgqfrms, 禁止转载 ???,侵权必究??!