使用 jQuery,如何从通过操作 DOM 添加的字段中获取表单数据?
我有一个表主体,可以通过 AJAX 在各种事件上获取其行(和表单字段)。一切工作正常,除了一部分:在操作表后,我无法从任何表行获取表单数据。
我已经尝试过 live() 函数,但我似乎无法获得正确的设置来提取表单数据。
有什么想法吗?
I have a table body that grabs it's rows (and form fields) via AJAX on various events. Everything is working fine, except one part: I can't obtain form data from any of the table's rows after it gets manipulated.
I've played around with the live() function, but I can't seem to get the right setup to pull in the form data.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过 http://api.jquery.com/serialize/ ?
Have you tried http://api.jquery.com/serialize/ ?
DOM 中的所有内容都可以从 jquery 访问,无论它是如何添加/操作的。
如果您想要更详细的答案,请向我们展示一些您所做的事情和想要做的事情的代码...
everything inside the DOM is accessible from jquery no matter how it got added/manipulated..
Show us some code of what you do and what you want to do if you want a more detailed answer...
我在我的代码中发现了这个问题。重建表后,我的字段名称与在页面加载时构建表时使用的字段名称略有不同。
感谢您的快速回复。
I found the issue in my code. Upon rebuilding the table, I had a slightly different field name for the fields than I used when building the table on page load.
Thank you for your quick responses.
听起来您可能需要重构该代码,以便在页面加载时构建表的相同代码稍后也会重建它。
It sounds like you may need to re-factor that code such that the same code that builds the table at page load also rebuilds it later on.