我有一个任务需要从输入值转换为格式对象数组,如下所示:
[{
id: 1,
worker_id: 2,
status:1
},{
id: 2,
worker_id: 2,
status: 1
},{
id: 3,
worker_id: 2,
status:1
}]
Run Code Online (Sandbox Code Playgroud)
我的输入有多行。
<!-- row1 -->
<input type="text" id="id" value="1"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<!-- row2 -->
<input type="text" id="id" value="2"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<!-- row3 -->
<input type="text" id="id" value="2"/>
<input type="text" id="worker_id" value="2"/>
<input type="text" id="status" value="1"/>
<input type="submit" value="submit" />
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 jQuery 中做到这一点?感谢您的任何帮助!
更新
单击按钮提交后,此格式可以传递到文本字段吗?
[[1,2,1],[2,2,1],[3,2,1]]
Run Code Online (Sandbox Code Playgroud)