如何在 JavaScript 中调用函数?
JavaScript 也允许我们编写自己的函数。要稍后在脚本中调用函数,只需要写该函数的名称即可。
示例
你可以尝试运行以下代码来学习如何在 JavaScript 中调用一个函数 −
<html>
<head>
<script>
function sayHello() {
document.write ("Hello there!");
}
</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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP