I have a div id="XYZ" with CSS specified width: 37%;
I then wish to use the px width of this div to set other widths, but I can only access the given css% value and not the computed px width of the div in the DOM. What am I doing wrong?
$( document ).on( "pagecreate", "#page", function( event ) {
var divWidth = $("#XYZ").width();
console.log('div XYZ width is ' + divWidth);
});
It outputs 37. Which is the css % value, but jquery width() SHOULD give me the computed width in px, shouldn-t it?
I was thinking that maybe the problem is that I-m asking at 'pagecreate' (same result in deprecated 'pageinit').
How can I get the computed width of the div?
pagecontainershow(if you're using jQM 1.4) event to get computed width. Atpagecreateevent, elements are invisible and still page has not taken full shape.pagecontainershowfires. jqmtricks.wordpress.com/2014/03/26/jquery-mobile-page-events