jQuery

(작성중) 마우스 영역

bang2001 2014. 8. 20. 13:51

$(window.document).click(function(event){

var auto_complete_box = $("#auto_complete_box");

var position = $(auto_complete_box).position();

var width = $(auto_complete_box).outerWidth();

var height = $(auto_complete_box).outerWidth();

var mouse_x = event.pageX;

var mouse_y = event.pageY;


//마우스 포인터가 auto_complete_box 밖의 영역을 클릭한 경우

if(

position.top > mouse_y ||

position.top+height < mouse_y ||

position.left < mouse_x ||

position.left+width > mouse_x)

{

auto_complete_box.hide();

}

});