|
Notes — Dynamic hiding/opening elements on the webpage (JavaScript). |
Back to Notes
Dynamic hiding/opening elements on the webpage (JavaScript).
n0xi0uzz
Tags:
html
javascript
div
To hide or open some elemet on the webpage, here is a simple JavaScript function:
function showBlock(id)
{
if (document.getElementById(id).style.display == 'none') {
document.getElementById(id).style.display='inline';
} else {
document.getElementById(id).style.display = 'none';
}
}
To use it you should pass id of element wich you want open or hide as parameter.
Here is the expamle whith the <div> tag:
<a href="#" onclick="showBlock('whypage'); return false;" class="menu">Title.</a> <div id="whypage" style="display:none" class="block">Some text</div>
By clicking on this link element will hide or open.
|
|
|
If you find a bug on our site please
report us.
|
24 / 584
Today we have 133 visits by robots. They want to kill all humans.
Registered users: 0
Online: 0
Page build time: 0.001 sec
|
|