How to collect all script tags of HTML page in a variable
问题 I would like to collect all the <script> ....</script> code section present in the HTML page in some variable. What should be the simpler way to do this, Any idea how it can be retrieved using JavaScript.?? Any help will be greatly appreciated. 回答1: To get a list of scripts you can use document.getElementsByTagName("script"); by tag document.scripts; Built-in collection document.querySelectorAll("script"); by selector $("script") jQuery by selector var scripts = document.getElementsByTagName(