toggle a element by id using javascript
<html>
<head>
<title>toggle a element by id using javascript</title>
</head>
<body style="background:lightgray">
<p>Click the button to test:</p>
<button onclick="toggle('hideMe')">Show/hide</button>
<div id="hideMe">I want to hide this by pressing the button above</div>
<script>
function toggle(id)
{
var e = document.getElementById(id);
if (e.style.display == "block" || e.style.display=="")
{
e.style.display = "none";
}
else
{
e.style.display = "block";
}
}
</script>
</body>
</html>
Comments
Post a Comment