Get width and height from a dynamically created elemeent (div)

  javascript, jquery

Im adding html to a modal window, as a pop-up. I have to get the width and height of one of those divs. When i call height it returns 0.

Is there a way to access these props, when they become relevant?
i’m using .on DOMNodeInserted trigger, but still returns 0.

document.getElementById('modal-content').innerHTML = html;

$(document).on('DOMNodeInserted', '.modal-body', function () {
            let video = $('#videoplayer');
            console.log(video.width());
}

Source: Ask Javascript Questions

LEAVE A COMMENT