想判断按钮事件很简单,只需要创建一个按钮(废话)然后定义一个函数就可以了,代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alert</title>
</head>
<body>
<button type="botton" onclick="myFunction()">点击我</button> <!--创建一个按钮-->
<script>
function myFunction() { //定义按钮被按下时运行的函数
window.alert("Hello,World!") //alert弹窗
}
</script>
</body>
</html>
日常偷懒
上一期