我有一个菜单,用户在其中进行交互。菜单选项有: 创建按钮,编辑按钮,删除按钮。 我必须确保当用户选择创建一个新按钮时,您可以激活一个功能;用户必须提供用于将按钮放置在屏幕上的坐标。 编辑按钮用于更改已经生成的按钮的位置。 删除按钮删除已经生成的按钮。如何在特定位置生成按钮?
<html>
<body>
<input type="button" value="create button" onclick="build()">
<input type="button" value="delete button" onclick="delete()">
<input type="button" value="edit button" onclick="edit()">
<script>
var x, y, z, k;
function build()
{
var button =document.createElement('button');
x = prompt("Inserisci posizione TOP");
y = prompt("Inserisci posizione Sinistra");
button.style.right = x;
button.style.left = y;
button.style.width = 50;
button.style.height = 50;
button.setAttribute("value","generated button");
document.body.appendChild(button);
//doesn't function
}
function delete()
{
}
function edit()
{
}
</script>
</body>
</html>
你试图使用位置固定的吗? –