我有一個菜單,用戶在其中進行交互。菜單選項有: 創建按鈕,編輯按鈕,刪除按鈕。 我必須確保當用戶選擇創建一個新按鈕時,您可以激活一個功能;用戶必須提供用於將按鈕放置在屏幕上的座標。 編輯按鈕用於更改已經生成的按鈕的位置。 刪除按鈕刪除已經生成的按鈕。如何在特定位置生成按鈕?
<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>
你試圖使用位置固定的嗎? –