Last active
September 23, 2019 20:23
-
-
Save henriquegogo/6c442b476279732336e0 to your computer and use it in GitHub Desktop.
Get all elements with id and return as a object model
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
var viewModel = [].reduce.call(document.querySelectorAll('[name]'), function(result, i) { | |
return Object.defineProperty(result, i.name, { | |
get: function() { return i.value }, | |
set: function(value) { i.value = value }, | |
configurable: true | |
}); | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment