单击div下面的元素?

时间:2016-01-07 12:50:20

标签: javascript jquery html5 css3

我可以给出一个例子:



__init__

.nightly{
  z-index: 9000; 
  position: fixed; 
  height: 100%; 
  width: 100%; 
  background-color: rgba(0,0,0,0.5);
}




想知道<div class="nightly"> </div> <div class="body"> <button>Test</button> <a href="#">Test 1</a> </div>&#34;透明&#34;点击,或者点击它下面的按钮,链接等?

2 个答案:

答案 0 :(得分:6)

在您的CSS中添加pointer-events : none;点击将通过。

答案 1 :(得分:0)

对于IE(来自here):

//This is an IE fix because pointer-events does not work in IE
$(document).on('mousedown', '.nightly', function (e) {

    $(this).hide();
    var BottomElement = document.elementFromPoint(e.clientX, e.clientY);
    $(this).show();
    $(BottomElement).mousedown(); //Manually fire the event for desired underlying element

    return false;

});