<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JavaScript计算值</title> </head> <body> <p>假设y=5,计算x=y+2,并显示结果.</p> <button type="button" onclick="myFunction()">点击这里</button> <p id="pid"></p> <script> function myFunction() { var y=5; var x=y+2; var demoP=document.getElementById("pid"); demoP.innerHTML="x="+x; } </script> </body> </html>
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com