[Javascript] Create Element

Table of Contents

Create Element Functions

function createInput(id,type){
var input = document.createElement("input");
input.type = type;
input.name = id;
input.id = id;
return input;
}
function createDiv(id,html){
var div = document.createElement("div");
div.id = id;
div.innerHTML=html;
return div;
}

Sử dụng

var frm=document.getElementsByTagName("FORM")[0];
frm.appendChild(createInput('img'+fid,'hidden'));
frm.appendChild(createDiv('showimg'+fid,''));
-soqiaualang_chentreu-]]>

Leave a Reply

Your email address will not be published. Required fields are marked *