When you do $(this).css('display','none'); the this element disappears and any static or relative elements located in the DOM after this, move up and occupy the area once used by the this element. They move up, because what display:none does is hiding the element AND removing the layout space occupied by it.
However, in your code you show and hide the element so fast, that produces no noticeable flickering. But the most important thing: The elementFromPoint() might in fact not read the element underneath, but the sibling element that got just moved up.
You should use $(this).css('visibility','hidden'); instead. It also hides the this element, but maintains the space there, causing no layout changes in the elements that follow.
When you do
$(this).css('display','none');thethiselement disappears and any static or relative elements located in the DOM afterthis, move up and occupy the area once used by thethiselement. They move up, because whatdisplay:nonedoes is hiding the element AND removing the layout space occupied by it.However, in your code you show and hide the element so fast, that produces no noticeable flickering. But the most important thing: The
elementFromPoint()might in fact not read the element underneath, but the sibling element that got just moved up.You should use
$(this).css('visibility','hidden');instead. It also hides thethiselement, but maintains the space there, causing no layout changes in the elements that follow.