开发者

How do you access non-standard attributes in Firefox JavaScript?

开发者 https://www.devze.com 2023-02-02 07:10 出处:网络
Basically in IE you can do something like this: <img metaDataAtt=\"type5\" src=\"...\" id=\"tag1\"/>

Basically in IE you can do something like this:

<img metaDataAtt="type5" src="..." id="tag1"/>

and then in the JavaScript do something like

var theImg = document.getElementById("tag1");
alert(theImg.metaDataAtt);

However, in firefox you can't. Is there some sort of hack to get around this?

Thanks, 开发者_开发问答Grae


document.getElementById('tag1').getAttribute('metaDataAtt');
0

精彩评论

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