Display or Hide Inline Text

[Total: 0    Average: 0/5]

This shows how to have IE and NS6 display or not display inline components.

Head Code:

<script> 
var isNS6=navigator.userAgent.indexOf("Gecko")!=-1?true:false;
var isIE=document.all?true:false;
function showhideinline(oDiv,flag){ 
if(isIE)
{
  if (flag) oDiv.style.display="inline" //if flag true - show the div 
  else oDiv.style.display="none" 
}
else if(isNS6)
{
  if (flag) document.getElementById("oDiv").style.display="inline" //if flag true - show the div 
  else document.getElementById("oDiv").style.display="none" 
}
} 
</script> 

<style> 
.tag{background:#f0f0d0;display:none} 
</style> 

Body Code:

first <input type=checkbox onclick='showhideinline(a,this.checked)'> 
second <input type=checkbox onclick='showhideinline(b,this.checked)'> 
third <input type=checkbox onclick='showhideinline(c,this.checked)'><br> 
<div id=a class=tag> 
first div is here<br>first<br> 
</div> 
<div id=b  class=tag> 
second div is here<br>second<br> 
</div> 
<div id=c  class=tag> 
third div is here<br>third<br> 
</div> 

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *