So, I need to know the width of an element with javascript, the problem I have is that the function fires too early and the width changes when the css is tottally applied. A
Quote OP:
"As I understood, the
$(document).ready()
function was fired when the document is completed,"
$(document).ready()
fires when the DOM ("document object model") is fully loaded and ready to be manipulated. The DOM is not the same as the "document".
W3C - DOM Frequently Asked Questions
You can try $(window).load()
function instead...
$(window).load(function() {
// your code
});
It will wait for all the page's assets (like images and fonts, etc.) to fully load before firing.