English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
以下のように:
<!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-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>
これで、編集者が皆さんに提供したJavaScriptの計算値をhtmlに埋め込む方法のすべてが終わりました。皆さん、呐喊教程を多く応援してください~