Hi all I am struggling with show/hide content. I have Xampp on my home computer which does not have a problem with the following code, but when I upload it to a host server, it does not hide the second division...can someone tell me whats wrong please?!! this is the code i have in my head section: <script language="javascript" type="text/javascript"> function emailcon(shID) { if (document.getElementById(shID+'-show').style.display != 'none') { document.getElementById(shID+'-show').style.display = 'none'; document.getElementById(shID+'-hide').style.display = 'block'; } else { document.getElementById(shID+'-show').style.display = 'inline'; document.getElementById(shID).style.display = 'none'; } </script> HTML: this is the code in my body: <div class='less' id="email-show"> some text </div> <div id="email-hide" class="more"> something else </div> HTML: and in my stylesheet i have .class{display:none;}
i just see that you missed the '-hide' in document.getElementById(shID).style.display = 'none'; note: this is an overlook, i did not test the code
Fixed. <script language="javascript" type="text/javascript"> function emailcon(shID) { if (document.getElementById(shID+'-show').style.display != 'none') { document.getElementById(shID+'-show').style.display = 'none'; document.getElementById(shID+'-hide').style.display = 'block'; } else { document.getElementById(shID+'-show').style.display = 'inline'; document.getElementById(shID+'-hide').style.display = 'none'; } </script> PHP:
This code is so interesting for me.. could you paste here the whole code to understand how can I add it in the right way at my html/css script please?