Using string methods to change DOM element parameters in Objects - Javascript Object

Javascript examples for Object:Object Method

Description

Using string methods to change DOM element parameters in Objects

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() {/*from   w ww  .java2s .  com*/
function myClass(id) {
    this.em = document.getElementById(id);
    Object.defineProperty(this, 'html', {
        set: function(val) {
            console.log('Set to ' + val);
        }
    });
}
(new myClass('foo')).html = 'bar';
    });

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

Related Tutorials