Click through div to underlying elements

后端 未结 16 2058
逝去的感伤
逝去的感伤 2020-11-21 06:19

I have a div that has background:transparent, along with border. Underneath this div, I have more elements.

Curre

16条回答
  •  滥情空心
    2020-11-21 06:30

    I'm adding this answer because I didn’t see it here in full. I was able to do this using elementFromPoint. So basically:

    • attach a click to the div you want to be clicked through
    • hide it
    • determine what element the pointer is on
    • fire the click on the element there.
    var range-selector= $("")
        .css("position", "absolute").addClass("range-selector")
        .appendTo("")
        .click(function(e) {
            _range-selector.hide();
    
            $(document.elementFromPoint(e.clientX,e.clientY)).trigger("click");
        });
    

    In my case the overlaying div is absolutely positioned—I am not sure if this makes a difference. This works on IE8/9, Safari Chrome and Firefox at least.

提交回复
热议问题