AS
Javascript
Visualizzare/nascondere un elemento
Codice
<!DOCTYPE html>
<html>
<head>
<script>
function visibleNotVisible(id)
{
var a=document.getElementById(id);
var b=a.style.visibility;
if(a.style.visibility=="hidden" || a.style.display=="none")
{
a.style.position='static';
a.style.visibility='visible';
a.style.display='block';
}
else(a.style.visibility=="hidden" || a.style.display=="none")
{
a.style.position='absolute';
a.style.visibility='hidden';
a.style.display='none';
}
}
</script>
<style>
div#clickMe{cursor:pointer;color:blue;}
div#clickMe:hover{text-decoration:underline;}
</style>
</head>
<body>
<div id="clickMe">
Click here
</div>
<div id="myDiv">
Example of function visibleNotVisible()
</div>
<script>
function myFunct(){visibleNotVisible("myDiv");}
document.getElementById("clickMe").addEventListener("click", myFunct);
</script>
</body>
</html>
Risultato
Click here
Example of function visibleNotVisible()