Search This Blog

Javascript: collapsable div





Source Code

<script type="text/javascript">
function update(){
    var button = document.getElementById("button1");
    var div = document.getElementById("div1");
    var action = button.value;
    if(action=="Show"){
        div.style.display='block';
        button.value = "Hide";
    } else if(action=="Hide"){
        div.style.display='none';
        button.value = "Show";
    }
}
</script>
<input id="button1" type="button" value="Show" onClick="update();"/><br/>
<div id="div1" style="background-color:#e0e0e0;display:none;">
Hi, there.<br/><br/><br/><br/><br/>
</div>

No comments:

Post a Comment