I have a parent jQuery object and a child jQuery element.
I'd like to see if the child is already contained within the parent. I was thinking of using jQuery's contains()
method. However, in Chrome and IE I always get true
returned and in FF6 I get an error a.compareDocumentPosition is not a function
Am I using this incorrectly? Is there a better way to achieve this?
Fiddle
Code:
<div class="metroContainer">
<div class="metroBigContainer">
<div id="big1" class="metroBig">
Stuffs 1
</div>
<div id="big2" class="metroBig">
Stuffs 2
</div>
</div>
<div class="otherContainer">
</div>
// I expect false, returns true
$.contains($('.metroBigContainer'), $('.otherContainer'))
I believe contains takes dom elements, not jquery objects:
$.contains($('.metroBigContainer')[0], $('.otherContainer')[0])
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