Click through div to underlying elements

后端 未结 16 2119
逝去的感伤
逝去的感伤 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条回答
  •  旧时难觅i
    2020-11-21 06:36

    I needed to do this and decided to take this route:

    $('.overlay').click(function(e){
        var left = $(window).scrollLeft();
        var top = $(window).scrollTop();
    
        //hide the overlay for now so the document can find the underlying elements
        $(this).css('display','none');
        //use the current scroll position to deduct from the click position
        $(document.elementFromPoint(e.pageX-left, e.pageY-top)).click();
        //show the overlay again
        $(this).css('display','block');
    });
    

提交回复
热议问题