Dynamically display length as type in Javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Dynamically display length as type in Javascript

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  ww  w .  j a  v  a2 s .c o m*/
var input = document.querySelector('input');
var p = document.querySelector('p');
var i = 0;
input.addEventListener('keyup', function() {
   p.innerHTML = input.value.length;
})
    }

      </script> 
   </head> 
   <body> 
      <input> 
      <p>The length of the value</p>  
   </body>
</html>

Related Tutorials