How to Make a Rule in the JavaScript According to the DIV [closed]

0

Good evening, personal.

I want a rule made through javascrit / Jquery to do the following: If the input with ID = 'A' is (IN) of the div with ID = 'B' do something ... That is, I want to know when a element is inside a certain div I can do a certain action.

    
asked by anonymous 01.02.2018 / 00:39

1 answer

1

You could use getBoundingClientRect() to get a collision box and use some math to test if the ClientRects are colliding.

Demo: no codepen . You can drag the green div to see. in this rule it turns red.

Reference link here

    
01.02.2018 / 02:25