Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14662 closed bug (notabug)

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

Reported by: lewkinglove@… 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>

Change History (2)

comment:1 Changed 10 years ago by dmethvin

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.

comment:2 Changed 10 years ago by anonymous

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

Note: See TracTickets for help on using tickets.