//Hide
document.getElementById("id").style.display = "none";
//Show
document.getElementById("id").style.display = "block";
<td class="post">
<a href="#" onclick="showStuff('answer1', 'text1', this); return false;">Edit</a>
<span id="answer1" style="display: none;">
<textarea rows="10" cols="115"></textarea>
</span>
<span id="text1">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</span>
</td>
<script>
function showStuff(id, text, btn) {
document.getElementById(id).style.display = 'block';
// hide the lorem ipsum text
document.getElementById(text).style.display = 'none';
// hide the link
btn.style.display = 'none';
}
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div id="box" style="background-color: salmon; width: 100px; height: 100px">
Box 1
</div>
<button id="btn">Hide div</button>
<script src="index.js"></script>
</body>
</html>
hide and show divs using javascript