使用JavaScript/jQuery移动表单中输入字段的位置

使用JavaScript/jQuery移动表单中输入字段的位置,javascript,jquery,html,forms,Javascript,Jquery,Html,Forms,我的网站上有以下表格 input a input b input c 是否可以使用jQuery完成以下操作 input a input c input b 请记住,表单仍然需要正确收集数据 请告知。是的,这是可能的,使用ids更容易,尽管技术相同,但如果您只知道要移动哪一个,那么: $('input:text:nth-child(3)').insertAfter($('input:text:nth-child(1)')); 或者,类似地: $('input:text:nth-chi

我的网站上有以下表格

input a
input b
input c

是否可以使用jQuery完成以下操作

input a
input c
input b

请记住,表单仍然需要正确收集数据


请告知。

是的,这是可能的,使用
id
s更容易,尽管技术相同,但如果您只知道要移动哪一个,那么:

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

或者,类似地:

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

参考资料:


是的,这是可能的,使用
id
s更容易,尽管技术相同,但如果您只知道要移动哪一个,那么:

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

或者,类似地:

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

参考资料:


哇,老兄,谢谢你;工作得很有魅力!我一直在谷歌上搜索,但找不到有效的东西。再次感谢!:)@维加,谢谢你!在中编辑,并用作第二个基于
id
的演示的基础。=)哇,老兄,谢谢你;工作得很有魅力!我一直在谷歌上搜索,但找不到有效的东西。再次感谢!:)@维加,谢谢你!在中编辑,并用作第二个基于
id
的演示的基础。=)