這樣為什么不行?通過js改變樣式
<!DOCTYPE html />
<title>無標題文檔</title>
<style>
#div1{width:100px;
height:100px;
background:red
display:none;}
<script>
window.onload=function(){
var odiv1=document.getElementById("div1")
odiv1.style.display="block";
}
</script>
</style>
</head>
<body>
<div id="div1">
</div>
</body>
</html>
2017-01-07
<!DOCTYPE html >
<html>
? <head>
? ? <title>MyHtml.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
? ? ? ? <style type="text/css">
? ? ? ? ? #div1{
? ? ? ? ? ? border:1px solid gray;
? ? ? ? ? ? width:100px;
? ? ? ? ? ? height:100px;
? ? ? ? ? ? display: block;
? ? ? ? ? }
? ? ? ? </style> ? ?
? ? ? ? <script type="text/javascript">
? ? ? ? function change(){ ?
? ? ? ? ?var d= document.getElementById("div1");
? ? ? ? ?d.style.display='none';?
? ? ? ? }
? ? ? ? function reset(){
? ? ? ? ?var d= document.getElementById("div1");
? ? ? ? ?d.style.display='block';?
? ? ? ? }
? ? ? ? </script>?
? </head>
??
? <body>
? ? ? <div ?id="div1" onclick="change()" >測試</div>
? ? ? <button onclick="reset()" >恢復</button>
? </body>
</html>
2017-03-09
少了個分號,還有就是style標簽的問題,別把script包在里面
2017-01-09
怎么感覺你好多標簽都不成對?
2016-12-29
<style></style>與<script>標簽是并列的,不能包含。行了,送積分哦,不懂可以追問
2016-12-29
<style></style>標簽是成對用的.
2016-12-29
display設置為none不顯示,把dispay的值改成block或inline.