Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
174
rated 0 times [  180] [ 6]  / answers: 1 / hits: 32771  / 10 Years ago, mon, march 10, 2014, 12:00:00

This is what happens on event:



$('div#pages').append($('<div class=page id=test>...</div>'));


And then, on another event it fails doing this:



var page = $('div.page#test'); // returns empty array


I've debugged, and the appended html appears in the document structure after appending, but fails to get selected. Doing the same in browser console works perfectly.

What could be the problem?


More From » jquery

 Answers
20

Use .find() http://api.jquery.com/find



var page = $('div#pages').find('div.page#test');

[#72065] Saturday, March 8, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mireyag

Total Points: 73
Total Questions: 107
Total Answers: 85

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
mireyag questions
Sun, Aug 15, 21, 00:00, 3 Years ago
Wed, Dec 16, 20, 00:00, 3 Years ago
Tue, Sep 1, 20, 00:00, 4 Years ago
Sun, Jul 5, 20, 00:00, 4 Years ago
;