如何在点击时调用JavaScript函数?
要通过单击JavaScript中的按钮来调用函数,请使用onclick。尝试运行以下代码以在JavaScript中调用onclick函数-
示例
<html>
<head>
<script>
function sayHello() {
document.write ("你好!");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "sayHello()" value = "Say Hello">
</form>
<p>Use different text in write method and then try...</p>
</body>
</html>热门推荐
10 给儿子生日祝福语 简短
11 新年祝福语简短的个性
12 新娘对伴娘祝福语简短
13 歌词祝福语高级文案简短
14 新年祝福语大全简短老师
15 生日祝福语简短明了 同事
16 餐前仪式祝福语简短
17 工人生日祝福语简短
18 新年探亲祝福语简短精辟