Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想写一个小脚本,一旦执行就会删除自己(为了记忆)。
为此,我添加了一个 ID。
有没有办法在不使用 ID 的情况下访问代码来自代码本身的脚本元素?
您可以根据它的索引来访问它(即它是第三个脚本标签,第二个等)
var scriptNum = 0; document.getElementsByTagName('script')[scriptNum];