K
K
Kooper_pro2018-03-16 17:00:39
JavaScript
Kooper_pro, 2018-03-16 17:00:39

How to get the height of the background image of a div?

Actually how to find out the size of the background image of the block?
https://codepen.io/anon/pen/wmzwRK

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dilik Pulatov, 2018-03-16
@Kooper_pro

var img = new Image;
img.src = $('#imgBlock').css('background-image').replace(/url\(|\)$/ig, "");

/* размер оригинальной картинки */
var bgImgWidth = img.width;
var bgImgHeight = img.height;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question