如果单击下面显示的按钮,我需要做什么才能在我的两个外部JS文件中执行代码?
<html>
<head>
<title>Vending Machine</title>
</head>
<body>
<script src="script.js"></script>
<script src="script2.js"></script>
<button type="button" onclick="">Press the Button</button>
</body>
</html>
答案 0 :(得分:1)
在你的javascript文件中应该有一个名为myFunction的函数,例如
<button onclick="myFunction()">Try it</button>
答案 1 :(得分:0)
您应该从点击
中的文件中调用2个函数<button type="button" onclick="function1(); function2();">Press the Button</button>