Jay Ghosh
Jay Ghosh

Reputation: 682

clientWidth of bootstrap modal returns 0

I have a bootstrap modal having id myModal.

In my javascript when i do something like

window.onload = function(){
         var container = document.getElementById("myModal");
         console.log(container.clientWidth);
}

It shows 0. How to get the clientWidth of a Bootstrap modal before it is opened?

Upvotes: 0

Views: 952

Answers (1)

user3272018
user3272018

Reputation: 2419

Jquery width works just fine

$('#ModalName').find('.modal-dialog').width()

For $('#ModalName') you are always getting wrong value.

Upvotes: 1

Related Questions