How to collect all script tags of HTML page in a variable

后端 未结 6 1073
闹比i
闹比i 2020-12-03 19:01

I would like to collect all the code section present in the HTML page in some variable.

What should be the simpler w

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 19:27

    Without jQuery :

    var scripts = document.getElementsByTagName("script");
    

    With jQuery :

    var scripts = $("script");
    

提交回复
热议问题