[問題] 設定ondblclick時,有辦法指定值嗎?
目前做個按鈕,可以點他的時候,在select 裡面加個option
並在點option兩下時,刪除該option
現在我打算設置option的ondblclick
在裡面加入刪除該物件的事件
可是不知道該怎麼設置
function addItem()
{
var newItem = document.createElement("option");
var inputText = document.getElementById("textbox").value;
if(inputText == "" || inputText == "請輸入內容")
{
alert("請輸入內容");
return;
}
newItem.text = inputText;
newItem.id = "oId" + oId++;
//newItem.ondblclick = "removeItem("+newItem.id+")"; //不能這樣用
itemBox.appendChild(newItem);
}
function removeItem(rmId)
{
for(var i =0; i<itemBox.length; i++)
{
if(itemBox.options[i].id == rmId)
{
itemBox.options.remove(i);
break;
}
}
}
我請問javascript是如何處理這種狀況的?
我不知道這個問題該用什麼關鍵字去google......
一直找不到想要的答案
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.41.109.80
→
01/07 19:31, , 1F
01/07 19:31, 1F
推
01/07 21:29, , 2F
01/07 21:29, 2F
→
01/07 21:29, , 3F
01/07 21:29, 3F
→
01/07 22:26, , 4F
01/07 22:26, 4F
→
01/09 16:59, , 5F
01/09 16:59, 5F
→
01/13 19:36, , 6F
01/13 19:36, 6F