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>

Blog Directory

Latest technology news.
 Patrick Stevens
 441  245556  6/21/2018




Blog Calendar