Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Create an input element
* @param {string} type
* @param {string|boolean} value
* @return {HTMLInputElement}
*/
function createInput(type, value) {
const el = document.createElement('input');
el.type = type;
if (type === 'checkbox') {
el.checked = value;
} else {
el.value = value;
}
return el;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment