in jQuery or Javascript, how would I detect if an img tag for example is overlapping another img tag?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do that by finding the offset of the elements, then finding the width & height of each. It’s then just a matter of simple math to determine if they’re overlapping.
I’m not going to do all the work for you, but this should get you on the right track:
All that’s left is to use the two offset’s .top & .left along with the widths and heights to determine if there’s an overlap. Check out the links to documentation in each of the functions in the first paragraph of my answer.