Taking div tag content and applying it to inline style - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Taking div tag content and applying it to inline style

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
             function data(){/*w  w w . java  2 s  .co m*/
                  return parseFloat(document.getElementById('my').innerHTML.trim());
             }
         
      </script> 
   </head> 
   <body> 
      <div id="sizeChange"> 
         <div id="my">
             40 
         </div> 
      </div> 
      <script type="text/javascript">
      document.getElementById("sizeChange").style.fontSize = data() + "px";
       
      </script>  
   </body>
</html>

Related Tutorials