javascript中創建一個按鈕
var body= document.body; ? ? ? ? ? ?
? var btn = document.createElement("input"); ?
? btn.setAttribute("type", "text"); ?
? btn.setAttribute("name", "q"); ?
? btn.setAttribute("value", "使用setAttribute"); ?
? btn.setAttribute("onclick", "javascript:alert('This is a text!');"); ? ? ?
? body.appendChild(btn); ?
畫橫線當中為甚alert括號里的內容只能用單影號
2016-04-17
"javascript:alert('This is a text!');" ?在外面已經有了一對雙引號(為了防止 引號匹配錯誤; 單引號與雙引號交叉使用)