0
我想能夠添加一個onclick處理程序到動態創建的div。添加onclick動態創建li標籤
這裏是我創建的元素:
function add_remove_roll_func(){
for (var i = 0; i<3; i++){
li_dice_side_one = createElementWithClass('li',arguments[i]);
add_remove_roll.appendChild(li_dice_side_one);
document.getElementById("ul");
}
}
add_remove_roll = createElementWithOutClass('ul');
dice_toolbar_wrapper_close.appendChild(add_remove_roll);
document.getElementById("dice-content-wrapper");
add_remove_roll_func("add","remove","roll");
我想添加刪除和滾動事件來調用不同的函數。
我試過add_remove_roll_func("'add' 'onclick="function'...)
但這並沒有自動神奇地工作:)。
我可以用jQuery來做,但我需要用原生javascript做到這一點。
什麼是'createElementWithClass'和'createElementWithOutClass'? –