判断鼠标是不是在某个元素中
// 判断鼠标是不是在某个元素中
function isInRect(event,obj){
event = event||window.event;
var mouseClickPostion = [event.clientX+document.body.scrollLeft,event.clientY+document.body.scrollTop],
listMemuPostion = [obj.offsetLeft, obj.offsetTop],
isInRect = ((mouseClickPostion[0]>=listMemuPostion[0]) && mouseClickPostion[1]>=listMemuPostion[1] && mouseClickPostion[0]- listMemuPostion[0]<=obj.offsetWidth && mouseClickPostion[1]-listMemuPostion[1]<=obj.offsetHeight);
return isInRect;
}
posted on 2014-02-05 13:43 jassonfish 阅读(442) 评论(0) 编辑 收藏 举报