【问题标题】:Draggable div property is not working in IE可拖动的 div 属性在 IE 中不起作用
【发布时间】:2012-12-26 12:02:07
【问题描述】:

我已经通过代码创建了一个可拖动的 DIV-

<div id="Age"
     draggable="true"
     ondragstart="drag(event)" width="50px" height="25px"
     style="background-color:Green;">Age</div>

DIV 在 Firfox、Crome 中运行良好,但在 IE、Opera 中无法运行。 有没有其他方法可以创建适用于所有浏览器的可拖动 DIV? 谢谢,

已编辑

<script  language="javascript" type="text/javascript">
function drag(ev) {
    ev.dataTransfer.setData("Text", ev.target.id);
   }</script>

谁能用 jQuery 证明我的解决方案?

【问题讨论】:

  • 请问IE版本
  • 我已经签入了 IE7、IE9 标准。
  • 在 IE9 中它会工作,我不知道 IE7 如果你显示 scipt 代码那么我可以给你一些建议
  • 也有可能您使用的是非常旧的 jQuery 和 jQuery UI 版本,请考虑升级。此外,您可以将所有 jQuery 代码合并到一个 document.ready 块中,这可能不会解决任何问题,但肯定会清理您的代码
  • @Saurabh:当然,见编辑。

标签: javascript jquery asp.net c#-4.0 asp.net-4.0


【解决方案1】:

正如您所要求的jquery 解决方案:-
在页面中添加这两个 JS 文件:-

  <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
  <script type="text/javascript" src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>

HTML:-

<div id="draggable" class="ui-widget-content">
    <p>Drag me around</p>
</div>

JS:-

  $(function() {
        $( "#draggable" ).draggable({
            drag: function(event, ui) {}
        });
    });

Fiddle :-
它也可以在 IE7 中运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 2014-04-06
    相关资源
    最近更新 更多