判断一个表格,如果一个tr的第一个td为空,则隐藏整个tr,jQuery能实现么
1个回答
展开全部
可以
<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#h").click(function(){
$("#t tr").each(function(){
if($("td:first",this).html() == ""){
$(this).hide();
}
});
});
});
</script>
</head>
<body>
<button id="h">hide</button>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666" id="t">
<tr>
<td>1</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>2</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#h").click(function(){
$("#t tr").each(function(){
if($("td:first",this).html() == ""){
$(this).hide();
}
});
});
});
</script>
</head>
<body>
<button id="h">hide</button>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666" id="t">
<tr>
<td>1</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>2</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询