1
我有以下javascript函數,它創建一個新行,其中包含按鈕作爲單元格項類型的不同單元格。那麼我怎麼才能在這裏實現按鈕功能的onClick
?如何在javascript中實現onclick對象?
我的代碼:
var propertyCell = row.insertCell(1);
var propertyName = document.createElement("input");
propertyName.type = "text";
propertyName.size = "6";
propertyName.id = "pName"+rowCount;
//alert(propertyName.size);
propertyCell.appendChild(propertyName);
var image1Cell = row.insertCell(6);
var image1 = document.createElement("input");
image1.type = "button";
image1.value = "Camera";
image1.size = "6";
image1.id = "image1"+rowCount;
//image1.onclick = function(){sdfkvk(dh,sdd)}
image1Cell.appendChild(image1);
this.id.split( 'E1')[1]應該image1.id返回的行數號,{}這將指向按鈕。 – kamui
是的..即使這工作正常:)謝謝你 – Smitha