Tuesday, March 31, 2015

Show, hide or toggle div - jQuery Snippet

Show, hide or toggle div - jQuery Snippet

Simple code snippet that let you show and hide div tag using jQuery whe you click on link

<a href="javascript:toggleDiv('myContent');" style="background-color: #ccc; padding: 5px 10px;">Toggle Button</a> 
<div id="myContent" style="background-color: #aaa; padding: 5px 10px;">
The content in this div will hide and show (toggle) when the toggle is pressed.
</div>
function toggleDiv(divId) {
$("#"+divId).toggle();
}

Disqus Comments