Sibling is an element that has the same parent as the current element.
The current element itself isn't a sibling.

The third li in the first ul has three siblings and it isn't a sibling of a li.hilite element.

The third ul clear the question: the Nine is sibling of Eleven and Eleven is sibling of Nine,
so both are colored.

Hope this help

Mauricio


-----Mensagem Original----- De: "mouqx xu" <[EMAIL PROTECTED]>
Para: <jquery-en@googlegroups.com>
Enviada em: domingo, 28 de setembro de 2008 00:17
Assunto: [jQuery] puzzles with "siblings"



the following is the example taked from
"http://docs.jquery.com/Traversing/siblings#expr";
The third li in the first ul does not colored with red in my FF3.0.3 and IE6.0
I supposed this is a bug.

by the way, the style in IE6.0 is ugly

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                   "http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
 <script src="http://code.jquery.com/jquery-latest.js";></script>

 <script>
 $(document).ready(function(){

   var len = $(".hilite").siblings()
                         .css("color", "red")
                         .length;
   $("b").text(len);

 });
 </script>
 <style>
 ul { float:left; margin:5px; font-size:16px; font-weight:bold; }
 p { color:blue; margin:10px 20px; font-size:16px; padding:5px;
     font-weight:bolder; }
 .hilite { background:yellow; }
</style>
</head>
<body>
 <ul>
   <li>One</li>
   <li>Two</li>
   <li class="hilite">Three</li>
   <li>Four</li>
 </ul>
 <ul>
   <li>Five</li>
   <li>Six</li>
   <li>Seven</li>
 </ul>
 <ul>
   <li>Eight</li>
   <li class="hilite">Nine</li>
   <li>Ten</li>
   <li class="hilite">Eleven</li>
 </ul>
 <p>Unique siblings: <b></b></p>
</body>
</html>

Reply via email to