W3Schools 在线编辑工具(TIY) V3.0
编辑的代码:
运行代码 »
©
w3s.com.cn
运行结果窗口大小:
300 x 150
<
!DOCTYPE
html
>
<
html
>
<
body
>
<
p
>
点击按钮就可以执行
<
em
>
displayDate()
<
/em
>
函数。
<
/p
>
<
button
onclick
="displayDate()"
>
点击这里
<
/button
>
<
script
>
function
displayDate()
{
document.getElementById(
"demo"
).innerHTML=Date();
}
<
/script
>
<
p
id
="demo"
>
<
/p
>
<
/body
>
<
/html
>
<!DOCTYPE html> <html> <body> <p>点击按钮就可以执行 <em>displayDate()</em> 函数。</p> <button onclick="displayDate()">点击这里</button> <script> function displayDate() { document.getElementById("demo").innerHTML=Date(); } </script> <p id="demo"></p> </body> </html>