Last active
December 9, 2017 18:08
-
-
Save robertsheacole/b76c3afd999e49cb1c2e4a5320f09c97 to your computer and use it in GitHub Desktop.
2 Way Binding with Vanilla JavaScript
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
function bind(items, event) { | |
items.forEach(item => { | |
item.addEventListener(event, e => { | |
items.forEach(otherItem => { | |
otherItem.value = e.target.value; | |
otherItem.innerHTML = e.target.value; | |
}); | |
}); | |
}); | |
} | |
// Pass in items as and array of DOM elements that you want to bind together. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment