如何在 onclick 事件中调用多个 JavaScript 函数?
javascriptweb developmentfront end technology更新于 2026/2/5 2:52:17
要在 on click 事件中调用多个 JavaScript 函数,请使用分号,如下所示 −
onclick="Display1();Display2()"
示例
<html>
<head>
<script>
function Display1() {
document.write ("Hello there!");
}
function Display2() {
document.write ("Hello World!");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "Display1(); Display2()" value = "Result">
</form>
</body>
</html>
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

