Ticket #4520 (closed bug: invalid)
Parent > child selector does not works as espected!
| Reported by: | andreabalducci | Owned by: | john |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | selector | Version: | 1.3.2 |
| Keywords: | selectors | Cc: | |
| Blocking: | Blocked by: |
Description
Using jquery-1.3.2-vsdoc2.js i found that the parent > child selector is selecting childs outside the parent.
With the .min and the standard .js all works fine.
try this:
<html> <head> <title> test </title> <style> #container > span{ color: navy; font-size:xx-large;} </style> <script type="text/javascript" src="jquery-1.3.2-vsdoc2.js"></script> <script type="text/javascript"> $(function(){
$('#container > span').css('background-color', 'gray');
}); </script> </head> <body>
<div id="container">
<span>gray background</span>
</div> <span>transparent background</span>
</body> </html>
Change History
comment:3 in reply to: ↑ 1 Changed 4 years ago by andreabalducci
Replying to dmethvin:
Where did you get that copy of jQuery?
http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js
Here the test with QUnit
<html>
<head>
<title> test </title> <script type="text/javascript" src=" http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js"></script> <link rel="stylesheet" href=" http://dev.jquery.com/view/trunk/qunit/testsuite.css" type="text/css" media="screen" /> <script type="text/javascript" src=" http://jqueryjs.googlecode.com/svn/trunk/qunit/testrunner.js"></script> <script type="text/javascript"> $(function(){
test("inside span", function() {
expect(2); var list = $('#container > span'); equals( list.length, 1, "span count inside the div = 1" ); equals( list[0].innerHTML, 'Inside div', "innerHTML of inside span" );
});
test("outside span", function() {
expect(2); var list = $('span').not('#container > span'); equals( list.length, 1, "span count outside the div = 1" ); equals( list[0].innerHTML, 'Outside div', "innerHTML of outside span" );
});
test("all span", function() {
var list = $('span'); equals( list.length, 2, "all span count = 2" );
});
}); </script>
</head> <body>
<div id="container">
<span>Inside div</span>
</div> <span>Outside div</span> <div id ="test_results">
<h1>QUnit example</h1> <h2 id="banner"></h2> <h2 id="userAgent"></h2>
<ol id="tests"></ol> <div id="main"></div>
</div>
</body>
</html>
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Where did you get that copy of jQuery?