07.20.08

Change the visibility of a html element

Posted in General Javascript | at 2:57 am by admin

I often use this code to toggle the visibility of a HTML element on the page. It is especially useful with forms and showing different option depending on what the user selects. Here is the code:-

function ToggleVis(element){
   var Target=document.getElementById(element);
   if(Target.style.display==""){
      Target.style.display="none";
   }else{
      Target.style.display="";
   }
}

Leave a Comment

You must be logged in to post a comment.