jquery - Swapping two text box values -


मेरे पास दो पाठ बॉक्स मान हैं: -

  var pickup = $ ('# txt -पिक अप'); Var गंतव्य = $ ('# txt-destination');   

और मैं दो मानों को स्वैप करना चाहता हूं: -

  pickup.val (destination.val ()); destination.val (pickup.val ());   

हालांकि, उपरोक्त दोनों मूल्यों को समान मान के रूप में हमेशा सेट किया जाएगा। (गंतव्य मान के समान)

क्या इन दोनों को एक ही समय में बदलने का एक तरीका है?

मैंने आपके लिए एक जेएसएफडियल बनाया:

  & lt; इनपुट आईडी = "txt-pickup" type = "text" / & gt; & Lt; इनपुट आईडी = "txt-destination" type = "text" / & gt; & Lt; इनपुट आईडी = "परिवर्तन" प्रकार = "बटन" मान = "स्वैप" / & gt; $ (Document) .ready (function () {$ ("# change")। पर ('click', function () {var pickup = $ ('# txt-pickup')। Val (); $ ('# ($ ('# Txt-destination')। Val ()); $ ('# txt-destination')। Val (पिकअप);});});   



Comments

Popular posts from this blog

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -