[英]onclick event is not firing in anchor tag in firefox 4.1
var ni = document.getElementById("fileDiv");
var objFileCount = document.getElementById("fileCount");
var num = (document.getElementById("fileCount").value - 1) + 2;
objFileCount.value = num;
var newdiv = document.createElement("div");
var divIdName = "file" + num + "Div";
newdiv.id = divIdName;
//newdiv.setAttribute("id", divIdName);
newdiv.innerHTML = '<input type="file" name="attachment" id="attachment"/> <a name="#" onclick="removeFile(' + divIdName + ');" style="color:blue;cursor:pointer;">Remove</a> ';
ni.appendChild(newdiv);
function removeFile(divName) {
alert(divName);
var d = document.getElementById("fileDiv");
d.removeChild(divName);
}
您忘記了divIdName的引號:
newdiv.innerHTML = '<input type="file" name="attachment" id="attachment"/> <a name="#" onclick="removeFile(\'' + divIdName + '\');" style="color:blue;cursor:pointer;">Remove</a> ';
另外,在發布問題時,請詳細說明您的問題; 不要只是發布代碼並期望得到答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.