I just don’t really understand why an ID is not a valid parent:
http://api.jquery.com/child-selector/
Valid:
$("#listequestions tr").click(function() {
$(this).addClass("success");
});
Not valid:
$("#listequestions > tr").click(function() {
$(this).addClass("success");
});
Can somebody help me to understand why?
Thank you.
A
tbodyis automatically inserted in a table if there is none.That’s why the only possible way to match
"#listequestions > tr"would be to give the id to athead, atfootor atbody.That’s one of the perils of the child selector.
Let’s suppose you have the following HTML :
Then the
trwould be matched by those two queries :$('#listequestions > tbody > tr')$('#listequestions tr')