jquery - 拖放在 IE 上工作正常,但在 Chrome/Firefox 上不行

标签 jquery asp.net internet-explorer google-chrome firefox

我正在使用 Visual Studio 2013 开发 asp.net C# 项目。 我在后面的代码中生成了一些 div,并在 Page_PreRender() 中影响了它们的 css 类。

C# 背后的代码:

HtmlGenericControl divRessource = new HtmlGenericControl("div");
divRessource.Attributes.Add("id", "div" + i.ToString());
divRessource.Attributes.Add("class", "dragRessources");

这些 div 也需要可拖放到后面代码生成的表中。 因此,我使用 Jquery 1.6.4 和 Jquery-ui 1.10.3 来实现此目的。

这是我的 JS 代码:

$(function () {
 $_dropEnd = null;

 $(".dragRessources").draggable({
   helper: "clone",
   revert: 'invalid',
   appendTo: "body",

   stop: function (event, ui) {
     $(this).appendTo($_dropEnd);

     $_dropEnd = null;
   }
  });

  $(".dropRessources").droppable({
    accept: ".dragRessources",
    tolerance: "touch",
    drop: function (event, ui) {
    $_dropEnd = this;  
   }
  });
});

CSS:

.dragRessources{
    cursor: move;
    color:Black;
    pointer-events: none;
    background-color:transparent;
    width:auto;
}

HTML(div 位于 divTabRessources 中):

<div id="divRessources" class="divRessources" runat="server" style="display:none;" >
   <div id="divTabRessources" class="divTabRessources dropRessources" style="display:block;" runat="server"></div>
</div>

我的问题是拖放在 IE 10 及更低版本上工作正常,但我无法在 Chrome 和 Firefox 上拖动 div。实际上,鼠标光标在 Firefox 和 chrome 中甚至没有变化。

有谁知道问题出在哪里吗?如果这是一个简单的问题,我很抱歉,但我已经参与这个项目一段时间了,我可能会错过一些明显的东西......

最佳答案

如果我删除了,对我有用(IE、FF、Chrome)

pointer-events: none;

CSS 声明。 启用此语句后,它甚至无法在 IE 中运行。 看这个fiddle

由于 CSS tricks 指针事件:

prevents all click, state and cursor options on the specified HTML element

关于jquery - 拖放在 IE 上工作正常,但在 Chrome/Firefox 上不行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21723602/

相关文章:

jquery - themerolleover jquery theme with scope 不适用于按钮 datepicker

javascript - 使用 javascript 更改表行名称属性

asp.net - 如何在 MVC 应用程序中共享常见的 js/css?

jquery - CSS、jQuery 和 IE。

javascript - 使用javascript在IE中设置cookie

jquery - 使用 jQuery 时 Internet Explorer 7 中的淡入淡出问题

jquery - 如何在 jQuery 中将 Bootstrap 复选框附加到数据表

c# - 最后读取的对象正在替换集合 ArrayList 中的所有项目

sql - ASPX 写入 SQL 数据类型

javascript - 边界图像 IE 8 和 IE 7 的解决方法