Почему у моего .name не было непрозрачности: 0 после: hover в классе hover? [Дубликат]

Согласен. После того, как он будет загружен в браузер пользователя, доступ к нему будет довольно простым. Поскольку вам нужно дождаться загрузки изображения, вам нужно подключиться к событию onload для img.

var width, height;

var img = document.createElement("img");
img.onload = function() {
    // `naturalWidth`/`naturalHeight` aren't supported on <IE9. Fallback to normal width/height
    // The natural size is the actual image size regardless of rendering.
    // The 'normal' width/height are for the **rendered** size.

    width  = img.naturalWidth  || img.width;
    height = img.naturalHeight || img.height; 

    // Do something with the width and height
}

// Setting the source makes it start downloading and eventually call `onload`
img.src = "http://your.website.com/userUploadedImage.jpg";
-3
задан Damian Kowalewski 30 March 2019 в 23:54
поделиться