Code: Select all
let imageElement = $('')
.attr('src', 'path/image.jpg')
.addClass('image')
.css({width: '100%', 'max-width': '100%', display : 'block'});
$('#div-container').prepend(imageElement);
$('.image').on('load', function (){
const images = document.getElementsByClassName('image');
let image = images[0];
let naturalWidth = image.naturalWidth; //Correct width was found.
let naturalHeight = image.naturalHeight; //Correct height was found.
let renderedWidth = image.clientWidth; // I get 0 here.
let renderedHeight = image.clientHeight; //I get 0 here.
});