Jump to content

[SOLVED] JS help


darkfreaks

Recommended Posts

i need help hiding and matching tables. maybe i am doing it wrong since it dont work ???

 

t= document.getElementsByTagNames();
if(t.match("</table>") { display: none!important; }
if(t.match("<table>") { display: none!important; }	
if(t.match("table") { display: none!important; }

Link to comment
Share on other sites

This code works, but it's not 100%.  For some reason it has to be clicked twice the first time (which is unacceptable), but it will point you in the right direction.

 

<script type="text/javascript">
function toggle()
{
  var tables = document.getElementsByTagName('table');
  
  for(var i = 0; i < tables.length; i++)
  {
    var x = tables[i];
      x.style.display = (x.style.display == "block") ?
        x.style.display = "none" : x.style.display = "block";
  }
}
</script>

Link to comment
Share on other sites

I've always checked for display:none, and assumed anything else is visible.

<script type="text/javascript">
function toggle()
{
  var tables = document.getElementsByTagName('table');

  for(var i = 0; i < tables.length; i++)
  {
    var x = tables[i];
      x.style.display = (x.style.display == "none") ?
        x.style.display = "block" : x.style.display = "none";
  }
}
</script>

Link to comment
Share on other sites

True, but my problem is that:

  for(var i = 0; i < tables.length; i++)
  {
    var x = tables[i];
      x.style.display

 

alert(x.style.display) will show a null value (empty alert) when I'm fairly certain it should show "block" or something. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.