get the size of a dynamic element that is not drawn - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:addClass

Description

get the size of a dynamic element that is not drawn

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script> 
  <style id="compiled-css" type="text/css">

.box/* w w w  .j a v  a 2  s  . c  o m*/
{
   width:200px;
}


      </style> 
  <script type="text/javascript">
    $(window).on('load', function() {
$(function(){
   var my = $(document.createElement("div")).addClass("box");
   console.log(my.width());
});
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials