JavaScript给按钮绑定点击事件(onclick)的方法
本文实例讲述了JavaScript给按钮绑定点击事件(onclick)的方法。分享给大家供大家参考。具体分析如下:
我们可以通过设定按钮的onclick属性来给按钮绑定onclick事件
<!DOCTYPEhtml>
<html>
<head>
<script>
functiondisplayDate()
{
document.getElementById("demo").innerHTML=Date();
}
</script>
</head>
<body>
<h1>MyFirstJavaScript</h1>
<pid="demo">Thisisaparagraph.</p>
<buttontype="button"onclick="displayDate()">
DisplayDate</button>
</body>
</html>
热门推荐
10 今天孩子高考祝福语简短
11 感谢朋友的祝福语简短
12 喜得贵子蛋糕祝福语简短
13 高考夸张祝福语大全简短
14 拜年同事祝福语大全简短
15 简短深沉的生日祝福语
16 简单生日祝福语简短大全
17 可爱小狗祝福语简短
18 客户去旅游祝福语简短