[英]Switching Image Stack with appendChild/replaceChild Function by Onclick
[英]AppendChild Link with onClick function
我正在嘗試在Javascript中使用appendChild來創建具有onClick屬性的鏈接。 我似乎無法使它工作或找到如何做這個簡單的任務。
var link=document.createElement("a");
link.appendChild(document.createTextNode("Link"));
link.href = '#';
link.onclick = 'loadScript()';
document.body.appendChild(link);
嘗試這個:
window.onload = function () {
var files = document.getElementById('files');
document.getElementById('addLink').onclick = function () {
var file = document.createElement('input');
file.type = 'file';
files.appendChild(file);
};
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.