gpt4 book ai didi

Javascript 不改变 css

转载 作者:太空宇宙 更新时间:2023-11-04 09:46:42 24 4
gpt4 key购买 nike

    <!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#b {
display: none;
}
</style>
<script type="text/javascript">
document.getElementById("b").style.display = block;
</script>
</head>
<body>
<h1 id="b">Hello</h1>
</body>
</html>

有谁知道我在这里做错了什么? CSS 不应该由 javascript 更改并显示 Hello。感谢您的帮助!

最佳答案

  <head>
<title></title>
<style type="text/css">
#b {
display: none;
}
</style>

</head>
<body>
<h1 id="b">Hello</h1>
<script type="text/javascript">
document.getElementById('b').style.display = "block";
</script>
</body>
</html>

试试这个更好地创建 custom.css 文件并在 head 部分链接。并创建 custom.js 文件并在/body 标记结束前链接到您的 html

关于Javascript 不改变 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39440236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com