javascript - 隐藏掉落的元素

标签 javascript c# jquery drag-and-drop

我有一个拖放操作,我想隐藏拖放的图像。我遇到的问题是,所有图像都具有相同的class,并且通过class drop隐藏会隐藏所有图像,包括尚未删除的图像。我已经尝试过 $(this).Hide(); 但是,这隐藏了 droppabble 而不是拖动的图像。

图像代码:

 using (The_Factory.Models.The_FactoryDBContext db2 = new The_Factory.Models.The_FactoryDBContext())
                {

                    string imageSource = "";

                    av = db2.Letter_Activity.ToList().FirstOrDefault(a => a.name == qs);

                    for (int i = 0; i < 4; i++)
                    {

                        if (av != null)
                        {
                            string imageBase = Convert.ToBase64String(av.image);
                            imageSource = string.Format("data:image/gif;base64,{0}", imageBase);


                            <img src="@imageSource" class="draggable correct" id="@av.name"/>

                        }
                    }
                }

这是我的 droppable 的代码

$("#droppable").droppable({
        accept: '.correct',
        drop: function (event, ui) {
            $(".correct").hide();
    });

    $("#playAgain").click(function () {
        location.reload(true);
    });
});

最佳答案

拖动的元素可以通过 ui 参数作为 ui.draggable 访问。

$("#droppable").droppable({
        accept: '.correct',
        drop: function (event, ui) {
            ui.draggable.hide();  // hide the element dragged...
    });

    $("#playAgain").click(function () {
        location.reload(true);
    });
});

关于javascript - 隐藏掉落的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894446/

相关文章:

c# - Xamarin.iOS MKLaunchOptionsDirectionsModeKey

Javascript 无法在 IE7 中加载

c# - 调试javascript代码

javascript - 如何使用 html 或 jsp 将数据以 xml 形式发布到服务器

c# - 使用 Linq 进行数学统计

c# - 将 HttpPostedFileBase 传递给 Controller ​​方法

javascript - 使用 id 值来搜索类

javascript - 我怎样才能摆脱这个自调用功能呢?

Javascript 多次翻转

javascript - 如何删除javascript中有趣的字符?