Reputation: 13999
I need to 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 {}
}}
Upvotes: 3
Views: 6942
Reputation: 146460
var scripts = document.getElementsByTagName("script");
for (i=0;i<scripts.length;i++){
if(scripts[i].src == "something.js"){
scripts[i].src = "this.js";
}
}
Upvotes: 8