0

I have the following form on my website

input a
input b
input c


Is it possible to have the following done using jQuery?

input a
input c
input b


Keep in mind that the form still needs to collect the data correctly.

Please advise.

1 Answer 1

5

Yes, that's possible, it's easier, albeit the same technique, with ids but if you just know which one you want to move, then:

$('input:text:nth-child(3)').insertAfter($('input:text:nth-child(1)'));

JS Fiddle demo

JS Fiddle of id-based approach (generously offered by Vega).

Or, similarly:

$('input:text:nth-child(3)').appendTo($('input:text:nth-child(1)').parent());

JS Fiddle demo.

JS Fiddle demo of id-based approach.

References:

Sign up to request clarification or add additional context in comments.

2 Comments

Wow dude, thank you; worked like a charm! I have been Googling this but couldn't find something that worked. Thanks again! :)
@Vega, thank you kindly! Edited in, and used as the basis for the second id-based demo. =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.