Skip to content

Instantly share code, notes, and snippets.

@mohsen1
Created September 26, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohsen1/55a1550c3bc0fc8819aea81dcf15d43b to your computer and use it in GitHub Desktop.
Save mohsen1/55a1550c3bc0fc8819aea81dcf15d43b to your computer and use it in GitHub Desktop.
/**
* 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