Created
December 28, 2017 19:42
-
-
Save doochik/542e64da671e6876f2f6d3826df9a237 to your computer and use it in GitHub Desktop.
This file contains 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
// data array | |
var foo = [{title: ‘1’, value: ‘1’ }, {title: ‘2’, value: ‘2’ }] | |
// html for new select | |
var html= [ | |
'<select>', | |
foo.map(function(item){ return '<option value="' + item.value + '">' + item.title + '</option>' }), | |
'</select>' | |
].join(''); | |
// find old select container in DOM | |
var oldSelectContainer = document.getElementById('select-container'); | |
// replace content with new select | |
oldSelectContainer.innerHTML = html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment