为什么代码没有显示隐藏的效果,求大神解答
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
</title>
<style type="text/css">
#txt{
width: 200px;
height: 150px;
background: red;
}
</style>
<script type="text/javascript">
function add(){
var a=document.getElementById("txt");
if (a.style.display=="block"){
a.style.display=="none"
}
else{
a.style.display=="block"
}
}
</script>
</head>
<body>
<input type="button" name="" id="" value="显示消失" onclick="add()"/>
<div id="txt"> </div>
</body>
</html>