指针事件在IE中没有表现得如预期

时间:2017-02-09 09:19:54

标签: javascript jquery html css internet-explorer

我遇到了pointer-events:none css的问题。我正在尝试停用combo box。 现在这个CSS在Chrome和Firefox中完美运行,但在IE中它可以部分工作。

虽然在IE中仍然禁用了组合框,但我可以点击组合框并显示不应该显示的下拉列表。请指导我是否可以使用相同的补丁。

以下是代码:



.pointer-events {
  pointer-events: none;
}

<select id="originPlaceId" name="originPlaceId" class="pointer-events" size="1" style="width:99%;">
  <option value="Tiger">Tiger</option>
  <option value="Lion">Lion</option>
</select>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

resolved here : stackoverflow

希望这会有所帮助:)

http://www.vinylfox.com/forwarding-mouse-events-through-layers/

您也可以尝试使用javascript解决方案:

http://jsbin.com/uhuto

function passThrough(e) {
    $(".box").each(function() {
       // check if clicked point (taken from event) is inside element
       var mouseX = e.pageX;
       var mouseY = e.pageY;
       var offset = $(this).offset();
       var width = $(this).width();
       var height = $(this).height();

       if (mouseX > offset.left && mouseX < offset.left+width && mouseY > offset.top && mouseY < offset.top+height)
         $(this).click(); // force click event
    });
}

$("#shield").click(passThrough);

var dthen = new Date();


var doPassThrough = true;
$('input').click(function(){
  doPassThrough =  !doPassThrough;
  if (doPassThrough){
    $("#shield").click(passThrough);
  } else {
    $('#shield').unbind('click', passThrough);
  }
});

答案 1 :(得分:-1)

当您在Internet Explorer中时,可以使用插件: pointer events polyfill

相关问题