Hide / Unhide in JavaScript

this will give the basic on how to hide / unhide <div> tag : 😀

Put this script in <head> section:

<SCRIPT TYPE=”text/javascript”>
function my_papar(nama_element)
var myElement = document.getElementById(nama_element);
if(myElement.style.visibility == “hidden”) {
myElement.style.position = “absolute”;
myElement.style.visibility = “visible”;
} else {
myElement.style.position = “absolute”;
myElement.style.visibility = “hidden”;

function my_hide(nama_element)
var c = nama_element;
c = setTimeout(“document.getElementById(‘”+c+”‘).style.visibility = ‘hidden'”, 333);


<input type=”button” onclick=”my_papar(‘myapit_hide_field’);” value=”Klik Sini”>
<div id=”myapit_hide_field” style=”position: absolute; visibility: hidden;”>

<li><a href=”#” onmouseover=”my_papar(‘menu_satu’);”
onmouseout=”my_hide(‘menu_satu’);”> Menu1</a></li>
<div id=”menu_satu” style=”position: absolute; visibility: hidden;”><br/>


save as “testjs.html” and try click on that button.

good luck.

— by apit


One thought on “Hide / Unhide in JavaScript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s