Javascript examples for Language Basics:eval
Using eval() on HTML Text
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload = function () {// ww w . j ava2s . c om var x = document.getElementById("myP").textContent; eval("var e = " + x + ";"); document.body.innerHTML = e(); } </script> </head> <body> <p id="myP">function () { if (5>1) { return 5; } } </p> </body> </html>