Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#4243 closed bug (fixed)

Selector ~ failed

Reported by: kanzi Owned by: john
Priority: major Milestone: 1.4
Component: selector Version: 1.4a1
Keywords: Cc:
Blocked by: Blocking:


$("#prev ~ div").css("border", "3px groove blue"); on "http://docs.jquery.com/Selectors/siblings#prevsiblings"

the border of div matched is not blue.

$("#prev ~ div").html() return null.

Change History (6)

comment:1 Changed 10 years ago by thorn

This example is contained on the iframe, so it's OK.

$('#prev~div', $('iframe')[0].contentDocument) works OK there.

But $('#prev~span', $('iframe')[0].contentDocument) doesn't. It's the real bug.

comment:2 Changed 10 years ago by igorbarmin

Repost from http://groups.google.com/group/jquery-dev/browse_thread/thread/aa580809104fce79

sample markup

<!-- 1.3.2. looks like broken -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<!-- Nightly. works --> <!--
<script type="text/javascript" src="http://code.jquery.com/nightlies/jquery-nightly.js"></script>
--><!-- 1.3.1. works --><!--
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
                console.log($('#prev ~ div').length);/*expecting 1, got zero in
        <div id="prev">1</div>

proposed fix (by Fabio Buffoni), works for me:

If you need a quick fix, removing the if

      if ( sibDir && elem.nodeType === 1 ) { ... }

in dirNode and dirNodeCheck should fix the problem

hope it helps

comment:3 Changed 9 years ago by john

Component: unfilledselector
Owner: set to john

Duplicates: #4451, #4569, #4605, #4606, #4931.

comment:4 Changed 9 years ago by john

#4759 is also a duplicate.

comment:5 Changed 9 years ago by john

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.