<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
/*
下面的函数在ie下面可以正常使用,但在firefox下面报错:obj.nextSibling.getAttribute is not a function
实在找不到原因了,请大家帮忙分析一下吧,我用的语法也应当是兼容ff的啊?怎么会这样呢?
*/
function test(obj)
{
while(obj.nodeName != "TR")
{
obj = obj.parentNode;
}
while(obj.nextSibling && !obj.nextSibling.getAttribute("att"))
{
obj = obj.nextSibling;
obj.style.display = "none";
}
}
</script>
</head>
<body>
<table width="500" border="1" align="center">
<tr att="测试">
<td><input type="button" onclick="test(this)" value="隐藏红色行" /></td>
</tr>
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr att="测试">
<td> </td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
/*
下面的函数在ie下面可以正常使用,但在firefox下面报错:obj.nextSibling.getAttribute is not a function
实在找不到原因了,请大家帮忙分析一下吧,我用的语法也应当是兼容ff的啊?怎么会这样呢?
*/
function test(obj)
{
while(obj.nodeName != "TR")
{
obj = obj.parentNode;
}
while(obj.nextSibling && !obj.nextSibling.getAttribute("att"))
{
obj = obj.nextSibling;
obj.style.display = "none";
}
}
</script>
</head>
<body>
<table width="500" border="1" align="center">
<tr att="测试">
<td><input type="button" onclick="test(this)" value="隐藏红色行" /></td>
</tr>
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr att="测试">
<td> </td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
/*
下面的函数在ie下面可以正常使用,但在firefox下面报错:obj.nextSibling.getAttribute is not a function
实在找不到原因了,请大家帮忙分析一下吧,我用的语法也应当是兼容ff的啊?怎么会这样呢?
*/
function test(obj)
{
while(obj.nodeName != "TR")
{
obj = obj.parentNode;
}
while(obj.nextSibling && (obj.nextSibling.nodeType==3 || !obj.nextSibling.getAttribute("att")))
{
obj = obj.nextSibling;
if(obj.nodeType!=3)
obj.style.display = "none";
}
}
</script>
</head>
<body>
<table width="500" border="1" align="center">
<tr att="测试">
<td><input type="button" onclick="test(this)" value="隐藏红色行" /></td>
</tr>
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr att="测试">
<td> </td>
</tr>
</table>
</body>
</html>