javascript - Is there a better way to "link" text inputs? -


i want have input boxes linked when type in one, shows in other (and vice versa). here's "codepen" shows how i'm doing currently.

http://codepen.io/anon/pen/yeabk/

it's pretty simple, feel there should easier way accomplish this. there problem method illustrated in codepen. you'll notice button fills 1 of boxes string. though content has been changed, "onchange" event doesn't run, , other input box not updated.

is there easier way fix problems i've been having?

this kind of problem databinding meant solve. there lots of libraries out there, popular angularjs (by google). http://angularjs.org/

see demo: http://jsfiddle.net/34zcs/2/ both inputs bound variable yourname:

<div ng-app>     <div>             <input type="text" ng-model="yourname" placeholder="a">         <input type="text" ng-model="yourname" placeholder="b">     </div> </div> 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -