问题描述
大家晚上好。我的 DnD 项目正在进行中,但是当我想删除错误放置的图像时,删除根本不会删除它。选择器被接受。我忽略了什么?我在问之前搜索了几个小时。代码来了……什么是堆栈片段?
function correct(tier,reihe,spalte) {
console.log("Falsch!");
switch (tier) {
case 1:
case 6:
case 8:
console.log("Tier: " + tier);
// var mytarget = document.getElementsByClassName("target");
var count = ((reihe - 1) * 3) + spalte;
console.log("Count: " + count);
// var mycell = document.querySelectorAll(".target table:nth-child(${count})");
var mycell = $('table.target tr:nth-child(' + reihe + ') td:nth-child(' + spalte + ')');
console.log(mycell);
console.log("Type: " + jQuery.type(mycell));
$('table.target tr:nth-child(' + reihe + ') td:nth-child(' + spalte + ')').find('img').remove();
console.log("Falsches Tier weg");
break;
case 3:
case 4:
case 7:
if (spalte == 1) {
console.log("Stimmt!");
empty[((reihe - 1) + spalte)] = false;
console.log(empty[((reihe - 1) + spalte)]);
} else {
// correct(tier,spalte);
}
break;
case 2:
case 5:
case 9:
if (spalte == 2) {
console.log("Stimmt!");
empty[((reihe - 1) + spalte)] = false;
console.log(empty[((reihe - 1) + spalte)]);
} else {
// correct(tier,spalte);
}
break;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table align="center" id="target">
<tr align="center">
<th align="center">Säugetiere</th>
<th align="center">Amphibien</th>
<th align="center">Reptilien</th>
</tr>
<tr>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
</tr>
<tr>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
</tr>
<tr>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
<td class="target droppable" data-droppable="true"></td>
</tr>
</table>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)