使用Javascript删除从不同页面呈现的整个表 [英] Delete the entire table rendered from different pages using Javascript

查看:86
本文介绍了使用Javascript删除从不同页面呈现的整个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张像这样的表:

 <table id="toc" class="toc" border="1" summary="Contents">
 </table>

所有这些页面都在一个页面中呈现。当我使用Javascript删除使用加载时的
。只删除一个表而不删除其他表。

in many pages .. All these pages are rendered in a single page. when I apply the Javascript to delete that using on load. Only one table is deleted and not the others.

我试图使用Javascript删除所有渲染页面中的表。怎么做?

I am trying to delete the tables in all the rendering pages using Javascript. How to do this?

编辑:

我自己找到了解决方案

Edit :
I myself found the solution

 <script type='text/javascript'>
    window.onLoad = load(); 
  function load(){var tbl = document.getElementById('toc'); 
   if(tbl) tbl.parentNode.removeChild(tbl);} 
 </script> 


推荐答案

真想完全删除该表吗?

var elem = documenet.getElementById('toc');

if (typeof elem != 'undefined')
{
  elem.parentNode.removeChild(elem);
}

你也可以隐藏表而不是删除它。

You could also hide the table rather than deleting it.

var elem = documenet.getElementById('toc');
elem.style.display = 'none';

如果您以后需要,您可以这样做:

If you need it later, you could simply do:

var elem = documenet.getElementById('toc');
elem.style.display = 'block';

这篇关于使用Javascript删除从不同页面呈现的整个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆