Tag Archives: Toggle Visibility

How to show/hide div with HTML and CSS only – Toggle visibility with CSS

HTML Example:   <a onclick="document.getElementById(‘myDiv’).style.display=’block’;" href="javascript:void(0)">Click Here to show  my div</a></div> <div class="anyclass" id="myDiv"> <p>Here goes the content you want to toggle the visibility</p> <a onclick="document.getElementById(‘myDiv’).style.display=’none’;" href="javascript:void(0)">Close [x]</a> </div>  
Posted in CSS | Also tagged , , , , | 2 Comments

Toggle (Show/Hide) any element with ID on page

Use this javascript code as a function to toggles the visibility of any element on the page. Put the below code inside the <body> tags and call it passing the ID of the element. (Element can be anything with an id attribute). Javascript Code:   <script type="text/javascript"> <!–     function toggle_visibility(id) {     [...]
Posted in JavaScript | Also tagged , , | Leave a comment