0
我想在點擊按鈕時將新節點添加到div。操作這必須作爲函數ADDNODE(本)將節點添加到div
<div id = "files">
<div>
<input type="file" name="main_photo">
<input type="button" value="add" onclick="addNode(this)">
<input type="button" value="delete" onclick="deleteNode(this)">
</div>
</div>
<script language="javascript">
function addNode(this){
var x = document.getElementById("files");
var y = x.getElementsByTagName("div");
var clone = y.cloneNode(true);
x.appendChild(clone);
};
</script>
您不能使用'this'作爲標識符,'this'是關鍵字! – undefined 2014-10-05 08:43:32