尝试使用一个input
元素(参见jsFiddle):
var button = document.createElement('input');
button.setAttribute('name', 'write');
button.setAttribute('type', 'button');
button.setAttribute('class', 'ui-button_S40button');
button.setAttribute('style', 'width: 100px;');
button.setAttribute('value', 'Write');
document.getElementById("write_testi").appendChild(button);
或者分配innerText
DOM 属性(demo):
var button = document.createElement('button');
button.setAttribute('type', 'button');
button.setAttribute('name', 'write');
button.setAttribute('class', 'ui-button_S40button');
button.setAttribute('style', 'width: 100px;');
document.getElementById("write_testi").appendChild(button);
button.innerText="Write";