gpt4 book ai didi

javascript - 我可以使用 JS 使符号可拖动吗?

转载 作者:行者123 更新时间:2023-11-30 08:47:03 26 4
gpt4 key购买 nike

我想做的是像“游戏”一样创建这个国际象棋。您应该能够自由地拖动符号,有点像您可以在网上找到的国际象棋助手。真的很简单。

但是我的问题是移动符号,有人能帮忙吗?

    `<!DOCTYPE html>
<html>
<head>
<style>
html, body {
width:100%;
height:100%;
}

.black {
background-color:silver;

}

table {
margin:auto;
text-align:center;
}
</style>
</head>
<body>
<table border="1" style="border:1px black solid;">
<tr>
<td width="40px" height="40px">&#9820;</td>
<td class="black" width="40px" height="40px">&#9822;</td>
<td width="40px" height="40px">&#9821;</td>
<td class="black" width="40px" height="40px">&#9819;</td>
<td width="40px" height="40px">&#9818;</td>
<td class="black" width="40px" height="40px">&#9821;</td>
<td width="40px" height="40px">&#9822;</td>
<td class="black" width="40px" height="40px">&#9820;</td>
</tr>
<tr>
<td class="black" width="40px" height="40px">&#9823;</td>
<td width="40px" height="40px">&#9823;</td>
<td class="black" width="40px" height="40px">&#9823;</td>
<td width="40px" height="40px">&#9823;</td>
<td class="black" width="40px" height="40px">&#9823;</td>
<td width="40px" height="40px">&#9823;</td>
<td class="black" width="40px" height="40px">&#9823;</td>
<td width="40px" height="40px">&#9823;</td>
</tr>
<tr>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
</tr>
<tr>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
</tr>
<tr>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
</tr>
<tr>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
<td class="black" width="40px" height="40px"></td>
<td width="40px" height="40px"></td>
</tr>
<tr>
<td width="40px" height="40px">&#9817;</td>
<td class="black" width="40px" height="40px">&#9817;</td>
<td width="40px" height="40px">&#9817;</td>
<td class="black" width="40px" height="40px">&#9817;</td>
<td width="40px" height="40px">&#9817;</td>
<td class="black" width="40px" height="40px">&#9817;</td>
<td width="40px" height="40px">&#9817;</td>
<td class="black" width="40px" height="40px">&#9817;</td>
</tr>
<tr>
<td class="black" width="40px" height="40px">&#9814;</td>
<td width="40px" height="40px">&#9816;</td>
<td class="black" width="40px" height="40px">&#9815;</td>
<td width="40px" height="40px">&#9813;</td>
<td class="black" width="40px" height="40px">&#9812;</td>
<td width="40px" height="40px">&#9815;</td>
<td class="black" width="40px" height="40px">&#9816;</td>
<td width="40px" height="40px">&#9814;</td>
</tr>
</table>
</body>

`

最佳答案

检查 jQueryUI 的

可拖动:http://jqueryui.com/draggable/

可放置:http://jqueryui.com/droppable/

有了这两个,你可以只使用 javascript 创建一个类似国际象棋的游戏

关于javascript - 我可以使用 JS 使符号可拖动吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21045839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com