Hi all i am new to jQuery. Suppose I have two HTML text boxes. How can I make it happen that if I write in text box A then same value goes to textbox B and if I write in B then it goes to A and same as delete the text. How can this be done in jQuery?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
This is a more dynamic way using jQuery:
You'll have to put a function call on each textbox's
onchange
events, that will take the value of one box and put it in the other.A slightly more efficient way than the most upvoted answer is:
http://css-tricks.com/snippets/jquery/keep-text-inputs-in-sync/
I ran into this challenge today. I made a small plugin to make the code more readable and to handle text inputs, but also select fe.
When you include the plugin, you can simply use
$("selector").keepInSync($("otherselector"));
This is quite easy:
Using Snicksie's method, you can see the live demo below. I have included a button to reset the textbox values as well.
http://jsfiddle.net/refhat/qX6qS/5/