Thứ Tư, 14 tháng 5, 2014

check if the cursor is in the bounds of an element jquery

 checkMouseInSearchRegion: (function(event) {
        var t = $("#dropdown_search_result");
        var mouseX = event.clientX + document.body.scrollLeft;
        var mouseY = event.clientY + document.body.scrollTop;
        if (mouseX >= t.offset().left && mouseX <= t.offset().left + t.width()
                && mouseY >= t.offset().top && mouseY <= t.offset().top + t.height()) {
            //console.log("true")
            return true;
        }
        return false;
    })