Monday, July 27, 2009

Hide Show Div

hi this is cool and simple javascript stuffs which HIDE and Show Details
using Div


<script language="javascript">
function toggle() {
var ele = document.getElementById("togText");
var text = document.getElementById("ShowText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "Click Me";
}
else {
ele.style.display = "block";
text.innerHTML = "Hide It";
}
}
</script>

Click Here to View Details
<a id="ShowText" href="javascript:toggle();">
Click Me </a>
<div id="togText" style="display: none">
< h1 > Hi, Kiran hows you? Hope u like this Cool stuff. < /h1 >
</div>



hope you like it ,

1 comment:

  1. Useful information.
    Toggle javascript show/hide divs:
    function toggle(divId) {
    var divArray = document.getElementsByTagName("div");
    for(i = 0; i < divArray.length; i++){
    if(divArray[i].className == divId){
    if(divArray[i].style.display != 'none'){
    divArray[i].style.display = 'none';
    }else{
    divArray[i].style.display = '';
    }
    }
    }
    }

    ReplyDelete