Toggle a DIV using JavaScript |
Here is a javascript function to toggle a div object. Once you click the Show/Hide link, the Div object will become invisible. It will become visible by clicking the Show/Hide link again. |
| Cut & Paste Script |
<html>
<head>
<title>Toggle DIV</title>
<script>
function toggle(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
</script>
</head>
<body>
<a href="javascript:void(0);" onClick="javascript:toggle(document.getElementById('txtToggle'));">Show/Hide</a>
<br>
<div id='txtToggle'>This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. </div>
<br>
</body>
</html> |
|
|
|
|
| |
|
|
|
|
| |
|
|
|