JSFiddle - React, Tailwind, and code Playground
JavaScript
var Flux=new Array();
var isIE =(document.all)?true:false;
Array.prototype.ArrayPos=function(quoi){
var Position=-1;
for (i=0;this[i];i++){ if (quoi==this[i]){Position=i;}
}
return Position;
}
$Close=function(Closing){
var FluxPos=Flux.ArrayPos(Closing)
var FluxLength=Flux.length;
var SpliceLength=FluxLength-FluxPos+1;
var AppendLot=Flux.splice(FluxPos+1,SpliceLength);
for(l=0;AppendLot[0];l++){
Closing.appendChild(AppendLot.shift())
}
if(Flux.length==1){document.body.appendChild(Flux.pop())}
}
var $C= function (HasH){
var Elt='';
var Special=false;
switch(HasH['type']){
case('radio' ): Elt=(isIE)?'<input name="'+HasH['name']+'">':HasH['obj'];
Special=(isIE)?true:false;
break;
case('checkbox' ): Elt=(isIE)?'<input name="'+HasH['name']+'">':HasH['obj'];
Special=(isIE)?true:false;
break;
default: Elt=HasH['obj'];
Special=(isIE)?true:false;
}
if(HasH['obj']=='label'){Elt=(isIE)?'<label for="'+HasH['for']+'">':HasH['obj'];
Special=(isIE)?true:false;
}
if(HasH['obj']=='select'){Elt=(isIE)?'<select name="'+HasH['name']+'">':HasH['obj'];
Special=(isIE)?true:false;
}
var Obj=document.createElement(Elt);
for (elt in HasH){
if (elt != 'obj'){
if(elt=='css'){ for(Styl in HasH['css']){Obj.style[Styl]=HasH['css'][Styl];}
}
else{
if(isIE){ if(!Special || (elt!='name' && elt!='for')){
Obj[elt]=HasH[elt];
}
}
else{ Obj[elt]=HasH[elt];
}
}
}
}
Flux.push(Obj);
return Obj;
}
function addInput(){
var DIV=$C({'obj':'input','name': "foo"});
$Close(DIV);
DIV=$C({'obj':'input','type': "button",'value':"ajouter","onclick":addInput});
$Close(DIV)
...