Skip to main content

Bug Tracker

Side navigation

#6195 closed bug (worksforme)

Opened March 01, 2010 04:54PM UTC

Closed October 10, 2010 02:40AM UTC

Parent > child selector problem

Reported by: jltouchette Owned by:
Priority: low Milestone: 1.4.3
Component: selector Version: 1.4.2
Keywords: Parent Child Cc:
Blocked by: Blocking:
Description

This doesn't work

$(document).ready(function(){

$("#myID > div.myClass").click(function(event){

}

}

Attachments (0)
Change History (4)

Changed March 01, 2010 06:06PM UTC by cowboy comment:1

What isn't it doing that you'd like it to do?

Changed March 01, 2010 06:07PM UTC by ajpiano comment:2

Can you please provide more information about the "bug" that is on display here? A test case? Otherwise this ticket will be closed as invalid shortly.

Changed May 27, 2010 02:04PM UTC by sakthikumar comment:3

Hi, the related scenario not working for me.

Below is my sample HTML to re-produce the issue.

Pls have the jquery.js files to run the script.

<html>

<head>

<script src="jquery-1.2.3.min.js"></script>

<!--script src="jquery-1.4.2.min.js"></script-->

<script>

$(document).ready(function(){

$("#main").next(".buttons > .clickme").bind("click", function(){

alert("Works in jQuery 1.2.3");

// Not working in 1.4.2

});

$("#main ~ .buttons > .clickme").bind("click", function(){

alert("Works in jQuery 1.4.2");

});

});

</script>

</head>

<body>

<span id="main">

</span>

<span class="buttons">

<a class="clickme">Click Me</a><br>

</span>

</body>

</html>

Changed October 10, 2010 02:40AM UTC by addyosmani comment:4

priority: → low
resolution: → worksforme
status: newclosed

As the original poster hasn't supplied a valid test case, I recreated one using the information provided and updated to use spans just in case sakthikumar (see above) also wanted to see how ID -> elem.className could be used:

http://jsfiddle.net/addyosmani/xQ8cK/1/

You can also achieve what you were trying to do using .children() as per here:

http://jsfiddle.net/addyosmani/xQ8cK/

Closing. Please feel free to re-submit your ticket if the issue persists.