JS新手咨询

<!DOCTYPE HTML>

<html>

<head>

  <title>随手练习</title>

  <meta charset="utf-8">

  <style>

  div { background:yellow;width:200px;height:300px;display:none;}

    </style>

    


</head>

<body> 

<input id="show" type="button" value="显示" />

<input id="hide" type="button" value="隐藏" />

<div id="div1"></div>

    

<script type="text/javascript">

    window.onload = function (){

  var show1 = document.getElementById("show");

var hide1 = document.getElementById("hide");

var div1 = document.getElementById("div");

 

show1.onclick = function (){

  div1.style.display = "block";

div1.style.background = "red";

};

hide1.onclick = function (){

   div1.style.display = "none";

};

};

</script>



</body>

</html>

hahaxiou
浏览 1025回答 1
1回答

田心枫

然而并没有看到你的问题?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java