开发者

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";
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜