我想点击按钮时触发一些JavaScript代码。 我想要点击按钮时console.log()被触发。 我尝试:点击触发JavaScript动作?
corel.html:
<!DOCTYPE html>
<html>
<head>
<title>Corelation</title>
<script src="jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="corel.js"></script>
</head>
<body>
<form id="tableVar">
Variable 1: <input type="text" id="var1"><br>
Variable 2: <input type="text" id="var2"><br>
<button onclick="myFunction()">Click me</button> <!-- type is button to not refresh -->
</form>
</body>
</html>
corel.js:
console.log("iniating app ...");
function myFunction() {
console.log('yeah');
}
我不明白什么不起作用?
这很好,您的控制台上有错误? –
控制台中是否有任何错误? –
确保您的JavaScript文件的引用也是正确的。 – Dummy