拖放不工作的网站

drag drop not working in website

本文关键字:网站 工作 拖放      更新时间:2023-09-26

当我尝试在jquery中使用拖放时,它在我的项目中不起作用,但是当我在小提琴中复制相同的html时,它正在为我工作。请帮助我为什么它不工作在我的项目,但当我采取相同的代码来摆弄它开始工作。

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
            <script src="//code.jquery.com/jquery-1.10.2.js"></script>
            <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
            <link rel="stylesheet" href="/resources/demos/style.css">
 $(function () {
                    $("#droppable").droppable({
                        stop: function (event, ui) {
                            alert('drop');
                        }
                    });
                    $(".draggable").draggable({
                        containment: 'document',
                        cursor: 'move',
                        revert: "invalid",
                    });
                    $(".droppable_widget,.draggable_widget").sortable({
                        connectWith: ".droppable_widget,.draggable_widget",
                        start: function (event, ui) {
                        },
                        stop: function (event, ui) {
                            var item = $(ui.item);
                            var to = item.parent().is(".droppable_widget");
                            var siblingsCount = item.siblings().size();
                            if (to && siblingsCount > 0) {
                                alert("only one item allowed here");
                                return false;
                            }
                        }
                    });
                    $(".connectedSortable").sortable({
                        connectWith: ".connectedSortable"
                    }).disableSelection;
                });


<div style="width: 50%; padding-left: 15px; padding-top: 15px; float: left;">
                                        <div id="users"><div class="draggable_widget ui-sortable"><ul class="connectedSortable ui-sortable" id="T1" style="">Team#0<li>1</li><li>1</li><li>2</li><li>2</li></ul></div><div class="draggable_widget ui-sortable"><ul class="connectedSortable ui-sortable" id="T2" style="">Team#1<li style="" class="">2</li><li>2</li></ul></div></div>
                                    </div>
<td class="tcol cnt"> <div><p id="H1">1</p><div style="height:100px;background-color:aqua;width:100px;" class="droppable_widget"></div><br><p id="H1">1A</p><div style="height:100px;background-color:aqua;width:100px;" class="droppable_widget"></div><br></div></td>

替换// http:// https://

  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

修改以上代码
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>