Javascript examples for DOM:Document querySelector
Use document.querySelector to get elements
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . ja 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>