代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html>
<head>
<title>上下移动和删除选项</title>
<style>
.container {
display: flex;
flex-direction: column;
gap: 10px;
}
.language-row {
display: flex;
align-items: center;
justify-content: space-between;
border: 2px solid black;
padding: 10px;
background-color: white;
}
.language {
color: black;
}
.action-buttons {
display: flex;
gap: 5px;
}
.action-button {
padding: 5px 10px;
background-color: #ccc;
border: 1px solid black;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="language-row">
<span class="language">Java</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
<div class="language-row">
<span class="language">Python</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
<div class="language-row">
<span class="language">C</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
</div>
<script>
// 上移操作
function moveUp(button) {
const row = button.parentNode.parentNode;
const previousRow = row.previousElementSibling;
if (previousRow) {
row.parentNode.insertBefore(row, previousRow);
}
}
// 下移操作
function moveDown(button) {
const row = button.parentNode.parentNode;
const nextRow = row.nextElementSibling;
if (nextRow) {
row.parentNode.insertBefore(nextRow, row);
}
}
// 删除操作
function deleteRow(button) {
const row = button.parentNode.parentNode;
row.parentNode.removeChild(row);
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。