Skip to main content

Bug Tracker

Side navigation

#4243 closed bug (fixed)

Opened February 25, 2009 10:28AM UTC

Closed December 08, 2009 06:25PM UTC

Last modified December 20, 2009 05:29PM UTC

Selector ~ failed

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

$("#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.

Attachments (0)
Change History (6)

Changed March 11, 2009 02:48PM UTC by thorn comment:1

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.

Changed March 13, 2009 03:14AM UTC by igorbarmin comment:2

Repost from

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

sample markup

<html>
<head>
<!-- 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">
        $(document).ready(function(){
                console.log($('#prev ~ div').length);/*expecting 1, got zero in
1.3.2*/
        });
</script>
</head>
<body>
        <div id="prev">1</div>
        <div>2</div>
</body>
</html> 

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

Changed October 08, 2009 05:31AM UTC by john comment:3

component: unfilledselector
owner: → john

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

Changed October 08, 2009 05:47AM UTC by john comment:4

#4759 is also a duplicate.

Changed December 08, 2009 06:25PM UTC by john comment:5

resolution: → fixed
status: newclosed
version: 1.3.21.4a1

Changed December 20, 2009 05:29PM UTC by john comment:6