zh-rocco / fe-notes

:memo: 前端笔记

Home Page:https://zh-rocco.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

【JS】你不知道的 DOM

zh-rocco opened this issue · comments

commented

document.currentScript

返回其所包含的脚本中正在被执行的 <script> 元素

值得注意的是,如果当前正在执行的代码是处在某个回调函数或者事件处理函数中的,那么 currentScript 属性不会指向包含那个函数的 <script> 元素,而是会返回 null

相关: current-script-polyfill