下面是一段html文档,你可以点击运行代码预览效果
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<style>
body {
font-family: sans-serif;
padding: 20px;
text-align: center;
}
h1 { color: #007bff; }
button {
padding: 10px 20px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
<title>html按钮点击</title>
</head>
<body>
<h1>Hello World</h1>
<p>欢迎您来到本站!</p>
<button id="btn">点击我</button>
<script>
document.getElementById('btn').addEventListener('click', function() {
alert('按钮被点击了!');
this.style.backgroundColor = '#dc3545';
this.innerText = '已点击';
});
</script>
</body>
</html>下面是另一个示例:
console.log("This is JS");
luby
console.log("This is JS");
2026-07-03 00:06