php - 使用 jQuery 编辑多个输入

标签 php jquery dynamic textinput

我有一个动态多文本输入:

<input type="text" id="text_1">
<input type="text" id="text_2">
<input type="text" id="text_3">
<input type="text" id="text_4">
<input type="text" id="text_5"> ....

如何使用 jQuery 获取每个文本输入的 id 进行编辑:

$('#form').submit(function(){
  $.post('include/setting.php', {
    text_(id): $('#text_(id)').val(), // <--
  }, 'json')
  return false;
})

使用 php 如何获取输入 id?

最佳答案

使用serialize()

$('#form').submit(function(){
  $('#form input[id]').each(function(){
   $(this).attr('name', $(this).attr('id'));
  });
  $.post('include/setting.php', $('#form').serialize());
  return false;
})

关于php - 使用 jQuery 编辑多个输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5553721/

相关文章:

javascript - 如何在window.location javascript中传递php变量

php - 使用volley在android中检索Json对象

jquery - 如何使用 jQuery 向后端提交值并接收结果

javascript - ClickEvent上的JavaScript声音仅适用于Google Chrome

c# - 如何调用动态类型的扩展方法?

dynamic - Fortran 77中的局部变量是静态的还是堆栈动态的?

c# - Silverlight 中的动态 TextBlock 字体大小

php - 学习编写 PHP 表单框架

php - 为什么我不应该在 PHP 中使用 mysql_* 函数?

jquery - IE 7 中的 CSS 问题