📜  js中加载文档时如何触发事件 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:14.182000             🧑  作者: Mango

代码示例1
document.addEventListener("DOMContentLoaded", ready);
function ready() {
    alert('DOM is ready');

    // image is not yet loaded (unless it was cached), so the size is 0x0
    alert(`Image size: ${img.offsetWidth}x${img.offsetHeight}`);
}