我想这就是你要找的。
var label = document.createElement('label');
var label2 = document.createElement('label');
label.innerHTML = "Hi";
label2.innerHTML = "How are you?";
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createElement("br"));
document.body.appendChild(label);
document.body.appendChild(label2);
更新1:
function f1(){
var label = document.createElement('label');
label.innerHTML = "Hi";
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createElement("br"));
document.body.appendChild(label);
}
function f2(){
var label2 = document.createElement('label');
label2.innerHTML = "How are you???";
document.body.appendChild(label2);
}
更新2
function f1(){
var a = new Array ( "Hi", "How are you?", "i am fine?");
var label = document.createElement('label');
label.innerHTML = a;
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createElement("br"));
document.body.appendChild(label);
}
function f2(){
var label2 = document.createElement('label');
label2.innerHTML = "How are you???";
document.body.appendChild(label2);
}