get Attribute 把它插入到我的 src ??,我不知道太多帮助我
get Attribute to insert it in my src ??, I do not know too much help me
我得到的结果"undefined":
代码 js:
document.getElementById("myImg").src = "hackanm"+x+".gif";
var x = document.getElementsByTagName("img")[0].getAttribute("data");
HTML:
<img data="WhatIWantToAdd" id="myImg" src="" >
顺序错误。即使声明了 x,它的值也会在赋值之前使用。因此未定义
var x = document.getElementsByTagName("img")[0].getAttribute("data");
document.getElementById("myImg").src = "hackanm"+x+".gif";
<img data="WhatIWantToAdd" id="myImg" src="" >
我得到的结果"undefined":
代码 js:
document.getElementById("myImg").src = "hackanm"+x+".gif";
var x = document.getElementsByTagName("img")[0].getAttribute("data");
HTML:
<img data="WhatIWantToAdd" id="myImg" src="" >
顺序错误。即使声明了 x,它的值也会在赋值之前使用。因此未定义
var x = document.getElementsByTagName("img")[0].getAttribute("data");
document.getElementById("myImg").src = "hackanm"+x+".gif";
<img data="WhatIWantToAdd" id="myImg" src="" >