TAG
JavaScript
Result
Run
License
<img id="myimg" src="http://resrc.devdic.com/img/bykind/alpha/150x135_flower.png" alt="Yellow rose" />
window.addEventListener("load", () => { const $elImg = document.getElementById("myimg"); const $promise = new Promise((resolve, reject) => { if($elImg.complete) { resolve($elImg.naturalWidth); } }); $promise.then(width => console.log(width)); });
Console
expand_less
License
License
by DevDic
Close