假设我的网页从上到下由几个表格组成,如:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
</body>
</html>
其中第二个<table> </table>中的内容是一个广告,我想直接在</html>后面直接添加一些代码使得第二个<table> </table>中的广告直接隐藏起来,这个代码如何写,不要用按钮的使它显示或隐藏的,直接隐藏这个<table> </table>中的内容就可以了。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
</body>
</html>
其中第二个<table> </table>中的内容是一个广告,我想直接在</html>后面直接添加一些代码使得第二个<table> </table>中的广告直接隐藏起来,这个代码如何写,不要用按钮的使它显示或隐藏的,直接隐藏这个<table> </table>中的内容就可以了。
document.getElementsByTagName("table")[1].style.diaplay="none"or document.getElementById("tableId").style.diaplay="none"
}
<!---->如果是获取的代码,你可以参考mingxuan3000(铭轩) 的方法:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> 1</td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> 2</td>
</tr>
</table>
<table width="1003" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1003" height="109" valign="top"><!--DWLayoutEmptyCell--> 3</td>
</tr>
</table>
</body>
</html>
<script language="javascript">
var tableobj = document.getElementsByTagName("TABLE");
tableobj[1].style.display = "none";
</script>