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.
 Steve Patterson
 419  245452  9/18/2017

FaceBook

Translate

Sponsors





Blog Calendar

Categories