Cleaning javascript variable scope by removing it's code from DOM

前端 未结 2 1117
情话喂你
情话喂你 2021-01-22 08:15

Hope this jquery based simple code will help to explain the issue.

html:



        
2条回答
  •  暖寄归人
    2021-01-22 09:07

    This certainly won't work as you expect. The JavaScript heap is not coupled to the DOM - once scripts have executed, and mutated the heap, you can't "unexecute" them by removing their associated source code.

    Global variables are typically set on the window object, so if you know the names, you can remove them from there. If you want to undo the effects of any JavaScript inside the block, you're pretty much out of luck.

提交回复
热议问题