Skip to main content

Bug Tracker

Side navigation

#14662 closed bug (notabug)

Opened January 02, 2014 10:07AM UTC

Closed January 04, 2014 09:55PM UTC

Last modified January 07, 2014 08:46AM UTC

jQuery Hierarchy Child Selector (“parent > child”) Not Work With Table

Reported by: lewkinglove@qq.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:
Description

test code.

=
<!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=utf-8" />
<script type="text/javascript" src="jquery.min.js"></script>
<title>无标题文档</title>
<style>
	table{border:1px solid #ccc;}
	table tr td{border-bottom:1px solid #ccc;}
</style>
</head>

<body>

<table id="tbl" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
  </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
  </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
  </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
  </tr>
</table>

<input type="button" value="showBugs" onclick="showBugs()" />
<input type="button" value="showWantEffect" onclick="showWantEffect()" />

</body>
<script type="text/javascript">
	function showBugs() {
    alert("#tbl-----Obj Count-----"+$("#tbl").length
           +"\\r\\n#tbl > tr-----Obj Count-----"+$("#tbl > tr").length
           +"\\r\\n#tbl > td-----Obj Count-----"+$("#tbl > td").length);
	
		$("#tbl > tr:last > td").css("border","2px solid red");
   }
   
   	function showWantEffect() {
		$("#tbl").find("tr:last>td").css("border","2px solid red");		
   }
</script>

</html>

Attachments (0)
Change History (2)

Changed January 04, 2014 09:55PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

Just get into any browser's DOM inspector and you will know why. If it's still unclear, ask for help on StackOverflow.

Changed January 07, 2014 08:46AM UTC by anonymous comment:2

@dmethvin Thank you. i know the reason now. very thanks