How to check for script src match, then reassign src
I need to开发者_如何学Go check every script
tag's src value and if there is a match, I would like to change that script tags src attribute... Something like this:
var scripts = document.getElementsByTagName("script")[0].src
for (i=0;i<scripts.length;i++){
if(scripts[i] == "something.js"){
document.getElementsByTagName("script")[i].src = "this.js"
}
else {}
}}
var scripts = document.getElementsByTagName("script");
for (i=0;i<scripts.length;i++){
if(scripts[i].src == "something.js"){
scripts[i].src = "this.js";
}
}
精彩评论