Emulating ng-model two way data binding in Vanilla Javascript - Javascript DOM

Javascript examples for DOM:Element innerText

Description

Emulating ng-model two way data binding in Vanilla Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>input event</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
 function foo(newValue) {//from w  ww. j  a v  a 2s.co m
       document.getElementById("#parsedEditor").innerText = bar(newValue);
 }
 function bar(text) {
     return text.replace(" ", "x");
 }

      </script> 
   </head> 
   <body> 
      <textarea id="#editor" oninput="foo(event.currentTarget.value)"></textarea> 
      <p id="#parsedEditor"></p>  
   </body>
</html>

Related Tutorials