Bug Tracker

Modify

Ticket #6195 (closed bug: worksforme)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

Description

This doesn't work

$(document).ready(function(){

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

}

}

Change History

comment:1 Changed 4 years ago by cowboy

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

comment:2 Changed 4 years ago by ajpiano

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.

comment:3 Changed 4 years ago by sakthikumar

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>

comment:4 Changed 4 years ago by addyosmani

  • Priority set to low
  • Status changed from new to closed
  • Resolution set to worksforme

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.