【发布时间】:2018-03-23 03:52:05
【问题描述】:
我对 javascript 和 html 完全陌生,我的 hello world 脚本无法正常工作。我想要一个按钮来触发警报。代码如下:
<!DOCTYPE html>
<html>
<head>
<title>hello world</title>
</head>
<body>
<button type="button" onclick="click()">
click me
</button>
<script>
function click(){
alert("hello world");
}
</script>
</body>
</html>
【问题讨论】:
-
它与元素的默认点击功能冲突,但您对点击功能不做任何事情。
标签: javascript html button onclick alert