My jQuery object looks like this:
var myJq = jQuery("<div class='a'></div><div class='b'></div>")
myJq.find(".a")
returns an empty jQuery object, apparently because find()
searches only the children of the nodes contained in a jQuery object, not the nodes themselves.
How can I grab one of the divs in myJq
using a selector?
You need to use .filter()
instead.
This will filter through items at the top level of the jQuery object.
myJq.filter(".a")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With