display
document.getElementById("content1").style.display="block"; 为十么会报错?
document.getElementById("content1").style.display="block"; 为十么会报错?
2017-07-23
这句话真的没问题,你应该是别的地方出现问题,你可以单独试试如下代码,我猜测你应该是获取的对象出现问题,你单词拼错之类
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Examples</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> <style type="text/css"> #content1{ width: 100px; height: 50px; border: 1px solid black; } </style> </head> <body> <div id="content1"></div> <script type="text/javascript"> window.onload=function(){ document.getElementById("content1").style.display="block"; } </script> </body> </html>
举报