CapturedTech.com

Captured Technology

Collapsing and Expanding HTML Code

Apr 01 2009

When in need of a quick way to expand and collapse HTML code on the client without posting back to the server of your web application, utilize the <div> tag with a style and some Javascript. Start with the style display set to either none or block and then interchange these two setting based upon a hyperlink click event.

<a href="javascript:;" onmousedown="if(document.getElementById('divMessage_1').style.display == 'none')
    { document.getElementById('divMessage_1').style.display = 'block'; }
else{ document.getElementById('divMessage_1').style.display = 'none'; }">Show/Hide</a>
<div id="divMessage_1" style="display:none">             
<p>This is something to show or hide.</p>
</div>

Blog Directory

Latest technology news.
 Patrick Stevens
 536  246408  4/17/2024

FaceBook

Translate