var ibutton = document.createElement('input');
ibutton.setAttribute('type', 'button');
ibutton.setAttribute('name', 'button');
ibutton.setAttribute('value', 'Delete');
ibutton.setAttribute('onclick', "deleteImage('<?php echo $_FILES['dt_file']['name'];?>', this,'<?php echo $image_type;?>');return false;");`
上面的代码创建了一个删除按钮。这仅适用于最新创建的按钮。
当我单击并选择图像时,使用此按钮动态创建图像,但每次单击并选择图像时,该事件onclick
仅适用于最新创建的按钮。之前创建的所有元素都没有工作事件,但它不显示任何错误。
上面的代码在 Mozilla 中运行良好,但在 IE9 中不行。