如下所示:
假设y=5,计算x=y+2,并显示结果.
<script> function myFunction() { var y=5; var x=y+2; var demoP=document.getElementById("pid"); demoP.innerHTML="x="+x; } </script>