i have searched a lot in SO. The text show/hide on click, worked only to show the div, when clicked on hide, it doesnt show another div.
I want something like this.
a text is displayed by defualt SHOW and div named formula1 is displayed, when clicked on show, it hides the test SHOW and hides the previous div formula1 and text HIDE Appears with another div Formula2
The below only showed one div, but i want both divs to be showed on each when clicked.
<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "show";
}
else {
ele.style.display = "block";
text.innerHTML = "hide";
}
}
</script>
</head>
<body>
<a id="displayText" href="javascript:toggle();">show</a> <== click Here
<div id="toggleText" style="display: none">peek-a-boo</></div>
</body>
anybody please help
Why dont you use JQUERY it will reduce the codes that are you writing. by using simple show() and hide() functions….
here is link .show() jquery selector and .hide() jquery selector
if you intersted in javascript then goto this URL simple javascript show hide div