javascript - Element width in chrome using jquery -


I need element width before adding body.

The following script is working fine in Firefox but google chrome

  & lt; Style & gt; Not in .testDiv {width: 150px; Height: 100px; } & Lt; / Style & gt; & Lt; Script & gt; Var div = "& lt; div class = 'testDiv' & gt; Divive content & lt; / div & gt;"; Warning ($ (div) .width ()); & Lt; / Script & gt;  

It outputs 150 in Firefox and 0 in Chrome

I have also tried

  $ (window) .load (function () {warning ($ (div). With ());});  

but it is doing the same thing ...

Update:

If I declare CSS inline this works but CSS class

  var div = "& gt; div style = 'width: 150px;' & Gt; Divise Content & lt; / div & gt; "; Warning ($ (div) .width ());  

This may be the reason, if your device has in-line CSS, it Will display your width correctly. Maybe CSS property does not load in Chrome

   

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -