<div class="windows" id="windows" style="display: block">
<div class="centent">
<div class="close" onclick="diy_close()">点击消失</div>
内容:hello word
</div>
</div>
<script type="text/javascript">
function diy_close(){
var E_id = document.getElementById("windows")
E_id.style.display='none'
}
</script >
把script脚本移到input后面就行了。像下面这样:<input type="button" id="button" value="点我">
<script type="text/javascript">
var a=document.getElementById('button')
a.onclick=function(){
alert("123")
}
</script>