Madhu
Madhu

Reputation: 2551

How to find which side of the div is clicked?

I need to know side of the div is clicked. How to find that. When i hover the border of the div the mouse will change to col-resize.

But I cant find at which side of the div the mouse is currenty..

Please help..

Upvotes: 0

Views: 66

Answers (1)

user3506641
user3506641

Reputation: 148

You can try to play with this:

$("#something").click(function(e){
   var parentOffset = $(this).parent().offset(); 
   //or $(this).offset(); if you really just want the current element's offset
   var relX = e.pageX - parentOffset.left;
   var relY = e.pageY - parentOffset.top;
});

Upvotes: 3

Related Questions