Javascript examples for Language Basics:eval
Call eval function to access DOM property
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <input type="text" onkeyup="myFunction(this.value)"> <p id="message"></p> <script type="text/javascript"> function myFunction(propName) {/* w ww .j a v a2s . c om*/ var p = document.getElementById("message"); try { p.innerHTML = eval(propName); } catch(e) { p.innerHTML = "invalid"; } } </script> </body> </html>