我有一个拖放操作,我想隐藏拖放的图像。我遇到的问题是,所有图像都具有相同的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/