A_Zim
2015-12-09 15:51
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html";charest="gb2312"/>
<title>函数调用</title>
<script type="javascript">
function add()
{
alert("飘过");
}
</script>
</head>
<body>
<form>
<input type="button" value="戳我" onclick="add()"/>
</form>
</body>
</html>
<script type="text/javascript">
type要写对,当然html5也支持不写
因为你还没有调用函数add();定义好函数要要调用它
script开始标签要这样写:<script type="text/javascript">
或这样写:<script>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html";charest="gb2312"/>
<title>函数调用</title>
<script type="javascript"><!--"text/javascript" 可以不写 一般浏览器都支持的--!>
function add()
{
alert("飘过");
}
</script>
</head>
<body>
<form>
<input type="button" value="戳我" onclick="add()"/>
</form>
</body>
</html>
JavaScript入门篇
741593 学习 · 9869 问题
相似问题