请写一个html目的是实现交互式h1标题
<!DOCTYPE html>
<html>
<head>
<title>Interactive H1 Title</title>
<style>
h1 {
cursor: pointer;
}
h1:hover {
color: red;
}
</style>
</head>
<body>
<h1 onclick="changeTitle()">This is an interactive H1 title</h1>
<pre><code><script>
function changeTitle() {
let newTitle = prompt("Enter new title:");
document.querySelector("h1").textContent = newTitle;
}
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/nDt 著作权归作者所有。请勿转载和采集!