Represent the object name by the function parameter - Javascript Object

Javascript examples for Object:Constructor

Description

Represent the object name by the function parameter

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/* w  w w.  ja v  a 2 s.  c o m*/

function AddStyle(prob, value) {
    Elem = document.getElementById('box');
    Elem.style[prob] = value;
}
AddStyle('color', 'green');


    }

      </script> 
   </head> 
   <body> 
      <div id="box">
         Hello
      </div>  
   </body>
</html>

Related Tutorials