我只是做一些简单的JavaScript作业,但我无法弄清楚为什么我的函数没有被调用。为什么我的函数没有被调用?
所有我有te功能现在做的是alert("test")
,因为我必须确保函数被调用,然后才能真正写出它的功能。 JS文件DOMassignment_3_ext.js
与HTML文件位于同一文件夹中。
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>DOM Assignment: #3</title>
<script src="DOMassignment_3_ext.js">
</script>
</head>
<body>
<h2>Christmas Mad Libs</h2>
<form name="words">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Body-part</td>
<td><input type="text" name="body"></td>
</tr>
<tr>
<td>Animal</td>
<td><input type="text" name="animal"></td>
</tr>
</table>
<input type="button" onlick="madlibs(name, body, animal)" value="Submit">
</form>
<p>
<b class="name"></b> the Red-<b class="body"></b> <b class="animal"></b><br>
Had a very shiny <b class="body"></b><br>
And if you ever saw it<br>
You would even say it glows<br>
And all of the other <b class="animal"></b><br>
Used to laugh and call him names<br>
They never let poor <b class="name"></b><br>
Join in any <b class="animal"></b> games<br>
</p>
</body>
</html>
JS:
function madlibs(name, body, animal){
alert("test");
}
你有一个错字:' '应该是''。 Typo属于'onclick'属性名称 – antyrat
'onclick'属性在输入时拼写错误。 – user3072619
'onlick' ...继续前进,开始舔你的电脑。 –