微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery-ui – jquery ui获取droppable元素的id,当删除一个项目时

删除一个项目时,我们如何获得droppable元素的id?这里我使用jquery ui和asp.net mvc。
<table id="droppable">
    <tr>
    <td style="width:300px;height:50px">Backlog</td>
    <td style="width:300px;height:50px">Ready</td>
    <td style="width:300px;height:50px">Working</td>
    <td style="width:300px;height:50px">Complete</td>
    <td style="width:300px;height:50px">Archive</td>
    </tr>
        <tr id="cart">
        <td id="BackLog" class="drag"  style="width:120px;height:50px;">

         <img class="draggable" id="1234" src="../../Content/themes/base/images/ui-icons_222222_256x240.png" />

        </td>
            <td id="Ready"  class="drag"  style="width:140px;height:50px">


            </td>
            <td id="Working" class="drag"  style="width:140px;height:50px">

            </td>
            <td id="Complete" class="drag" style="width:140px;height:50px">


            </td>
            <td id="Archive" class="drag" style="width:140px;height:50px">

            </td>
        </tr>
    }
   </table>

在这里,我想移动图像在Ist列到其他列,并获取该列的ID。
对于拖放我使用脚本

<script type="text/javascript">
    $(function () {
        $(".draggable").draggable({ containment: '#imageboundary',axis: "x" });
        $("#droppable").droppable({
            drop: function (event,ui) {                                      
                $.ajax({
                    type: "POST",url: '/Project/AddToPhase/' + $(ui.draggable).attr("id"),success: function (data) {
                        $('.result').html(data);
                    }
                });
            }
        });
    });
</script>

解决方法

获取draggable和droppable元素的ID,请使用以下命令:
$('.selector').droppable({ drop: Drop });

function Drop(event,ui) {
  var draggableId = ui.draggable.attr("id");
  var droppableId = $(this).attr("id");
}

对不起可能有点晚了,但我刚刚开始使用jquery,需要确切的事情。

原文地址:https://www.jb51.cc/jquery/185107.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐