Looking for guidance on how to combine two buttons in the same div using closures.
var form = [
{
type: 'button',
label: 'Reset'
},
{
type: 'button',
label: 'Submit'
}
];
for (var i = 0; i < form.length; i++) {
var obj = form[i];
var element = document.createElement("div");
switch (obj.type) {
case "button":
var wrapHtml = document.createElement("div");
var wrapHtmlAttr = document.createAttribute("class");
wrapHtmlAttr.value = "buttons-group";
wrapHtml.setAttributeNode(wrapHtmlAttr);
var button = document.createElement('button');
var textButton = document.createTextNode(obj.label);
button.appendChild(textButton);
wrapHtml.appendChild(button);
element.appendChild(wrapHtml);
break;
}
var div = document.getElementById("form");
div.appendChild(element);
}
Seeking advice on combining the two buttons into one div called buttons-group. Any help or suggestions are appreciated!