<style> #cont h3 { border-width: 2px 2px 0; border-style: solid; border-color: #000; margin-bottom: 0; } #cont div { border-width: 0 2px 2px; border-style: solid; border-color: #000; } #cont.hide div { display: none } #cont.hide h3 {border-bottom-width: 2px} </style> <div id="cont"> <h3>Заголовок</h3> <div>text<br>text<br>text<br>text<br></div> </div> <script> document.getElementById("cont").getElementsByTagName("h3")[0].onclick=function() { this.parentNode.className= this.parentNode.className ? "":"hide"; } </script>
this.parentNode.className ? "":"hide";
<script type="text/javascript"> function showhide(elem) { document.getElementsByClassName(elem)[0].style.display = document.getElementsByClassName(elem)[0].style.display ? 'block':'none'; } </script> <a class="show" style="display: block" onclick="showhide('hide');" href="#">Открыть</a> <div class="hide" style="display: none"> #1234567890# </div>
document.getElementsByClassName(elem)[0].style.display ? '':'none';