Created
October 15, 2019 02:02
-
-
Save blackChef/f1dad62ed5efe4ff9a84bf50b39ef564 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const item = function(id) { | |
return ` | |
<input type="text" name="${id}"/> | |
`; | |
}; | |
const list = function(ids) { | |
return ` | |
<div> | |
${ids.map(item)} | |
</div> | |
`; | |
}; | |
const form = function(ids) { | |
return ` | |
<form action=""> | |
${list(ids)} | |
<button type="submit">submit</button> | |
</form> | |
`; | |
}; | |
const render = function(ids) { | |
const target = document.querySelector('#container'); | |
target.innerHTML = form(ids); | |
}; | |
// <form action=""> | |
// <div> | |
// <input type="text" name="0"/> | |
// <input type="text" name="1"/> | |
// ... | |
// </div> | |
// <button>submit</button> | |
// </form> | |
const ids = [0,1,2,3,4]; | |
render(ids); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment