我编写这个函数是为了将<p>
标记中的文本框中的值推送到数组中,它运行得很好。
$(document).ready(function(){
$("#form_timesheet").submit(function(e){
var arr=[];
var i=0;
$("#addedRows p").find("input[type=text]").each(function(){
arr.push($(this).val());
i++;
});
});
现在我想通过同一个数组传递一个隐藏字段值和这个文本框值。我如何通过编辑行'$("#addedRows p").find("input[type=text]").each(function()'
Standej基本上是对的,只需修改他的答案如下:
$("#addedRows p").find("input[type=hidden], input[type=text]").each(function(){
您只需要添加
$("#addedRows p").find("input[type=hidden]").each(function(){
arr.push($(this).val()); // and add whatever value in it