Javascript: Display Toggle (Revised)
A simpler version of this script. Revised and improved:
Then call like so using the id you've given to the doc element:
<!-- JS: TOGGLE DISPLAY -->
<script type="text/javascript">
<!--
function toggle_display(element_id) {
if ( document.getElementById(element_id).style.display == 'none' ) {
document.getElementById(element_id).style.display = '';
} else {
document.getElementById(element_id).style.display = 'none';
}
return;
}
//-->
</script>
<!-- end JS: TOGGLE DISPLAY -->
<script type="text/javascript">
<!--
function toggle_display(element_id) {
if ( document.getElementById(element_id).style.display == 'none' ) {
document.getElementById(element_id).style.display = '';
} else {
document.getElementById(element_id).style.display = 'none';
}
return;
}
//-->
</script>
<!-- end JS: TOGGLE DISPLAY -->
Then call like so using the id you've given to the doc element:
<div id="toggle_block" style="background:blue;">now you see it</div>
<a onclick="toggle_display('toggle_block')" href="#toggle_block">show/hide</a>
<a onclick="toggle_display('toggle_block')" href="#toggle_block">show/hide</a>
1 Comments:
thnx ..it helps me
Post a Comment
Subscribe to Post Comments [Atom]
<< Home