Well, it's not so noob question, as this plugin returns value in a non-trivial way:
The second mode is to compare one set of elements against another and return only the elements that overlap.
$('#div1').overlaps('#div2');
In this example, if #div1
and #div2
overlap, the returned jQuery object will have both of them. If not, only #div1
.
So the solution is to check the length of the plugin's resulting object - and compare it with sum of lengths of the compared jQuery objects. If these are the same, the elements overlap; if not, they don't. )
In this particular example, you can just compare result's length with 2, like this:
if ( $('#div1').overlaps('#div2').length === 2 ) { // they overlap }
... as in valid DOM there can be exactly one element with a given ID.