I have piece of offline html like so:
<img src="../img/button.png"/>
and when I try to access the src attribute in JS, I get a different value than what's written in the html:
var s = myimg.src; // equals 'file:///V:/test/test1/img/button.png'
It's as if the value got resolved somewhere between the html and my call to 'src' attribute. How do I get the "original" value instead of the resolved one?
tnx
使用getAttribute
var s = myimg.getAttribute('src')
如果您读取属性而不是src
属性,则会获得原始值:
var s = myimg.getAttribute('src');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.