आप जिस इमेज की चौड़ाई चाहते हैं, उसके लिए निम्न में से किसी को आज़माएं:
myImg.setAttribute('width', '5px');
या
myImg.width = '5';
या
myImg.style.width = '5px';
आप बैकग्राउंड इमेज में चौड़ाई और ऊंचाई जोड़ने के लिए निम्न कोड भी आज़मा सकते हैं:
var myImg = new Image(5,5); myImg.src = 'https://www.example.com';